mysql5.7
- 下载并安装源
1
2
3wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'
sudo rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
yum repolist all | grep mysql
安装
1
sudo yum install mysql-community-server
更改数据目录
1
2
3
4
5
6
7
8
9chown -R mysql:mysql /root/data/soft/mysql
vi /etc/my.cnf
#修改数据目录
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
datadir=/root/data/soft/mysql
socket=/root/data/soft/mysql/mysql.sock启动
1
2
3
4
5
6
7
8
9service mysqld start
#查看错误日志
tail -200 /var/log/mysqld.log
#因为修改了目录 需要再初始化
cd /root/data/soft/mysql
rm -rf *
chown -R mysql:mysql .
mysqld --initialize --user=mysql --console
service mysqld start登录和修改密码
1
2
3
4
5
6
7
8#获取密码
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -P3308 -p
select @@log_error;
set password for 'root'@'localhost'=password('root@123');授权登录
1
2GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root@123' WITH GRANT OPTION;
FLUSH PRIVILEGES;客户端
workbench解决中文乱码
1
2
3set global character_set_server=utf8;
set global character_set_database=utf8;
show variables like '%char%';