一、使用phpmyadmin
1.点击账户, 点击root列localhost的修改权限
2.点击登录信息,主机名选择【任意主机】,点击右下角执行即可。可以以指定ip, 59.110.47.33或59.110.47.*
3.开放数据库端口,默认3306,如宝塔开放端口
4. navicat连接数据库
5.使用root用户连接上mysql后只能看到information_schema数据库
(1) 修改用户权限 执行:
update user set `Select_priv` = 'Y',`Insert_priv` = 'Y',`Update_priv` = 'Y',`Delete_priv` = 'Y',`Create_priv` = 'Y',`Drop_priv` = 'Y',`Reload_priv` = 'Y',`Shutdown_priv` = 'Y',`Process_priv` = 'Y',`File_priv` = 'Y',`Grant_priv` = 'Y',`References_priv` = 'Y',`Index_priv` = 'Y',`Alter_priv` = 'Y',`Show_db_priv` = 'Y',`Super_priv` = 'Y',`Create_tmp_table_priv` = 'Y',`Lock_tables_priv` = 'Y',`Execute_priv` = 'Y',`Repl_slave_priv` = 'Y',`Repl_client_priv` = 'Y',`Create_view_priv` = 'Y',`Show_view_priv` = 'Y',`Create_routine_priv` = 'Y',`Alter_routine_priv` = 'Y',`Create_user_priv` = 'Y',`Event_priv` = 'Y',`Trigger_priv` = 'Y',`Create_tablespace_priv` = 'Y' where user='root' and host='%';
(2)更新 执行:flush privileges;
二、远程连接操作mysql(ssh)
1、查找安装目录
# find / -name mysql
2、进入mysql
# /usr/bin/mysql -u root -p
3、进入数据库
//进入mysql数据库
mysql> use mysql
mysql> select Host,User from user;
4、添加权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
%可以是域名【59.110.47.33,59.110.47.*】,password为密码
ALL PRIVILEGES ON 后面的.*表示所有数据库,即完全访问权限,可以指定为特定数据库。
5、刷新
//强制刷新
mysql> flush privileges;
三、忘记mysql密码
https://www.cnblogs.com/ivictor/p/9243259.html