Linux安装MySQL 5.7
1、上传到/usr/local , 解压并重命名 为mysql
tar -zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz mv mysql-5.7.26-linux-glibc2.12-x86_64 mysql
2、创建mysql用户,并授予权限
adduser mysql chown mysql:mysql -R /usr/local/mysql
3、安装MySQL
cd /usr/local/mysql ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
3.1随机密码为最后一行,一定要复制出来
4、修改配置文件 /etc/my.cnf (一般系统自带该文件,没有就手动创建)
vi /etc/my.cnf
[mysqld] port=3306 datadir=/usr/local/mysql/data socket=/usr/local/mysql/mysql.sock user=mysql max_connections=100 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 #忽略大小写 lower_case_table_names=1 #设置编码 character-set-server=utf8 collation-server=utf8_general_ci #IP绑定 #bind-address=192.168.8.100 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid #客户端连接设置 [client] # 和上面要相同才行 socket=/usr/local/mysql/mysql.sock default-character-set=utf8
5、开启mysql服务
./support-files/mysql.server start
6、将mysql进程放入系统进程中
cp support-files/mysql.server /etc/init.d/mysqld
7、重启MySQL
service mysqld restart
8、设置MySQL环境变量
vim /etc/profile export PATH=$PATH:/usr/local/mysql/bin source /etc/profile
9、登陆MySQL(使用随机密码)
mysql -u root -p
10、修改密码(将密码修改成root)
alter user 'root'@'localhost' identified by 'root' ;
11、设置远程连接
use mysql; update user set user.Host='%' where user.User='root'; flush privileges;
12、开放端口
# 1、查看暴露的端口号 iptables-save # 2、开放端口号 firewall-cmd --zone=public --add-port=3306/tcp --permanent # 3、重新加载 firewall-cmd --reload
标签:5.7,--,mysql,mysqld,usr,Linux,MySQL,local From: https://www.cnblogs.com/manmanblogs/p/17552869.html