Mysql安装
- 版本: 8.0
- 添加源
yum local install https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
- 安装
yum install mysql-community-server
Mysql配置
-
初始化
sudo mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
-
启动mysql
systemctl start mysqld
-
设置mysql开机自启
systemctl enable mysqld
-
查看初始密码
grep 'temporary password' /var/log/mysqld.log
-
进入mysql
mysql -u root -p
-
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Huang|12345'
-
查看版本
select version(); +-----------+ | version() | +-----------+ | 8.0.16 | +-----------+ 1 row in set (0.00 sec)
-
查看端口
show global variables like 'port'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3306 | +---------------+-------+ 1 row in set (0.04 sec)
-
远程访问
use mysql; update user set host = '%' where user = 'root'; flush privileges