Linux 安装MySql8.0.*
安装mysql源
yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装mysql
yum install mysql-community-server
安装mysql的开发包,以后会有用
yum install mysql-community-devel
启动mysql
systemctl start mysqld.service
查看mysql启动状态
出现pid
证明启动成功
获取mysql默认生成的密码
grep 'temporary password' /var/log/mysqld.log
选中的就是密码。
换成自己的密码
mysql -uroot -p
Enter password:输入上页的密码,右键复制粘贴下来就可以了,进入mysql
更换密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourPassWord4!';
这个密码一定要足够复杂,不然会不让你改,提示密码不合法;大小写加数字加符号
退出mysql并试用下新密码,命令quit;
mysql> quit;
再连接测试下密码
mysql -uroot -p
确认密码正确
到此,mysql安装成功。
mysql 开启远程登录访问。
首先,确认你的服务器是否开启3306端口,若开启,登录mysql
[root@~ /]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.7.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql;
Database changed
mysql> grant all privileges on *.* to root@'%' identified by "password";
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| localhost | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| 192.168.1.1 | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| % | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
+--------------+------+-------------------------------------------+
3 rows in set (0.00 sec)
此时,远程访问就开启成功了