标签:bin CentOS local mysql5.7 36 shigj usr mysql root
1、下载地址到国内得开源镜像网站下载
2、解压缩
[root@shigj ~]# ls
mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
[root@shigj ~]# tar -zxvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
mysql-5.7.36-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-5.7.36-linux-glibc2.12-x86_64/bin/myisamchk
mysql-5.7.36-linux-glibc2.12-x86_64/bin/myisamlog
3、重命名并移动文件
[root@shigj ~]# mv mysql-5.7.36-linux-glibc2.12-x86_64 /usr/local/mysql
4、创建mysql用户组和用户并修改权限
[root@shigj ~]# groupadd mysql
[root@shigj ~]# useradd -r -g mysql mysql
5、创建数据目录并赋予权限
[root@shigj ~]# mkdir -p /usr/local/mysql/data #创建目录
[root@shigj ~]# chown mysql:mysql -R /usr/local/mysql/data #赋予权限
6、配置my.cnf
[mysqld]
#端口号
port = 3306
#mysql-5.7.36文件的路径
basedir=/usr/local/mysql
#mysql-5.7.36数据路径
datadir=/usr/local/mysql/data
log-error=/usr/local/mysql/data/mysql.err
#最大连接数
max_connections=600
#编码
character-set-server=utf8
#skip-grant-tables
default-storage-engine=INNODB
#不区分大小写
lower_case_table_names=1
#绑定ipv4
bind-address=0.0.0.0
#设置传输包限制,默认1M
max_allowed_packet=64M
#设置缓冲池大小:
innodb_buffer_pool_size=1024M
#设置隔离级别
transaction-isolation=read-committed
#设置时区
default-time-zone='+8:00'
#设置密码验证默认加密方式
#default-authentication-plugin=mysql_native_password
explicit_defaults_for_timestamp=true
[mysql]
#编码
default-character-set=utf8
7、初始化数据库
进入mysql的bin目录
出现报错需要安装依赖包
[root@shigj ~]# cd /usr/local/mysql/bin/
[root@shigj bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql --initialize
./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@shigj bin]# yum install libaio-devel.x86_64
7、查看密码
[root@shigj bin]# cat /usr/local/mysql/data/mysql.err
2021-11-10T08:45:20.242160Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-11-10T08:45:20.288796Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-11-10T08:45:20.346361Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 895b2959-4202-11ec-8dae-00163e03473d.
2021-11-10T08:45:20.347667Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-11-10T08:45:21.167981Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2021-11-10T08:45:21.167993Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2021-11-10T08:45:21.168567Z 0 [Warning] CA certificate ca.pem is self signed.
2021-11-10T08:45:21.811242Z 1 [Note] A temporary password is generated for root@localhost: egFw0x=%-E/e
8、启动mysql,并更改root 密码
先将mysql.server放置到/etc/init.d/mysql中
[root@shigj bin]#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@shigj bin]# /etc/init.d/mysql start
[root@shigj bin]# service mysql restart
配置环境变量
[root@shigj ~]# vi /etc/profile
最后添加export PATH="$PATH:/usr/local/mysql/bin"
[root@shigj ~]# source /etc/profile
修改密码
SET PASSWORD = PASSWORD('one123456');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
修改远程连接
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
标签:bin,CentOS,local,mysql5.7,36,shigj,usr,mysql,root 来源: https://blog.csdn.net/qq_27745471/article/details/121251311
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。