centos安装mysql
1、下载并安装mysql官方的yum repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2、使用yum进行mysql安装
yum -y install mysql57-community-release-el7-10.noarch.rpm
3、导入密钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
4、安装mysql服务
yum -y install mysql-community-server
5、启动mysql服务
systemctl start mysqld.service
6、查看mysql运行状态命令
systemctl status mysqld.service
7、在日志文件中查找随机密码
grep "password" /var/log/mysqld.log
8、进行root登录
mysql -uroot -p
输入刚刚随机的密码后
9、干掉密码校验策略,执行这个命令之前必须得执行一遍修改用户密码的操作 ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘Admin123456+’;
uninstall plugin validate_password;
10、开启远程访问
grant all privileges on *.* to 'root'@'%' identified by 'Admin123456+' with grant option;
11、修改mysql语言,先查看语言status
先退出mysql:exit
编辑my.cnf 文件
vi /etc/my.cnf
添加下面代码
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
lower-case-table-names=1
重启mysql服务
service mysqld restart
再次登录mysql查看状态: mysql -uroot -pAdmin123456+ 输入status
�