首先,找到MySQL官网
- 下载对应的rpm文件
如:CentOS 7上选择:mysql80-community-release-el7-3.noarch.rpm
yum install mysql80-community-release-el7-3.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
- 安装MySQL
yum install mysql-community-server
- 启动MySQL
systemctl start mysqld
- 查看MySQL状态
systemctl status mysqld
- 查找密码
sudo grep 'temporary password' /var/log/mysqld.log
- 修改密码
shell>shell> mysql -uroot -p
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
- 开启可以远程连接
mysql> use mysql;
mysql> select host from user where user='root';
mysql> update user set host='%' where user='root';
mysql> flush privileges;
至此,即可连接Linux上的MySQL。
|