su root
根据提示输入密码,切换权限
apt-get install mysql-server -y
安装mysql8
service mysql start
启动mysql
mysql -V
查看版本
mysql -uroot -p
回车登录mysql(第一次不需要密码)
mysql>use mysql; # 指定数据库mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
alter user修改root登录密码
mysql>alter user root@localhost identified with mysql_native_password by '你的密码';
授权所有ip访问root用户
mysql>update user set host = '%' where user='root';
授权某一个IP远程登录
mysql>grant all privileges on *.* to 'root'@'192.168.222.1' with grant option;
授权所有IP远程登录(请勿在正式环境进行此操作)
grant all privileges on *.* to 'root'@'%' with grant option;
vim /etc/mysql/mysql.conf.d/mysqld.cnf
修改mysql配置bind-address允许其他IP访问
14 [mysqld]
15 #
16 # * Basic Settings
17 #
18 user = mysql
19 # pid-file = /var/run/mysqld/mysqld.pid
20 # socket = /var/run/mysqld/mysqld.sock
21 # port = 3306
22 # datadir = /var/lib/mysql
23
24
25 # If MySQL is running as a replication slave, this should be
26 # changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
27 # tmpdir = /tmp
28 #
29 # Instead of skip-networking the default is now to listen only on
30 # localhost which is more compatible and is not less secure.
31 bind-address = 127.0.0.1 192.168.222.1 #0.0.0.0为所有IP都可访问
32 mysqlx-bind-address = 127.0.0.1
33 #
34 # * Fine Tuning
35 #
36 key_buffer_size = 16M
网友评论