mysql root 维护



修改root密码:

mysql -uroot -paaa
mysql> use mysql;
mysql> UPDATE user SET password=password("aaa") WHERE user=‘root‘;  
mysql> flush privileges;
mysql> exit;

# 重启服务
service mysqld restart



增加用户:

insert into user(Host,User,Password) values("localhost","root",password("113355"));
insert into user(Host,User,Password) values("%","root",password("113355"));
insert into user(Host,User,Password) values("iz11jtfubrxz","root",password("113355"));

更新用户信息使得用户可以查看mysql库:

update user set Select_priv =‘Y‘ where user = ‘root‘;
update user set Insert_priv =‘Y‘ where user = ‘root‘;
update user set Update_priv =‘Y‘ where user = ‘root‘;
update user set Delete_priv =‘Y‘ where user = ‘root‘;
update user set Create_priv =‘Y‘ where user = ‘root‘;
update user set Drop_priv =‘Y‘ where user = ‘root‘;
update user set Reload_priv =‘Y‘ where user = ‘root‘;
update user set Shutdown_priv =‘Y‘ where user = ‘root‘;
update user set Process_priv =‘Y‘ where user = ‘root‘;
update user set File_priv =‘Y‘ where user = ‘root‘;
update user set Grant_priv =‘Y‘ where user = ‘root‘;
update user set References_priv =‘Y‘ where user = ‘root‘;
update user set Index_priv =‘Y‘ where user = ‘root‘;
update user set Alter_priv =‘Y‘ where user = ‘root‘;
update user set Show_db_priv =‘Y‘ where user = ‘root‘;
update user set Super_priv =‘Y‘ where user = ‘root‘;
update user set Create_tmp_table_priv =‘Y‘ where user = ‘root‘;
update user set Lock_tables_priv =‘Y‘ where user = ‘root‘;
update user set Execute_priv =‘Y‘ where user = ‘root‘;
update user set Repl_slave_priv =‘Y‘ where user = ‘root‘;
update user set Repl_client_priv =‘Y‘ where user = ‘root‘;
update user set Create_view_priv =‘Y‘ where user = ‘root‘;
update user set Show_view_priv =‘Y‘ where user = ‘root‘;
update user set Create_routine_priv =‘Y‘ where user = ‘root‘;
update user set Alter_routine_priv =‘Y‘ where user = ‘root‘;
update user set Create_user_priv =‘Y‘ where user = ‘root‘;
update user set Event_priv =‘Y‘ where user = ‘root‘;
update user set Trigger_priv =‘Y‘ where user = ‘root‘;



my.cnf配置

[mysqld]
#datadir=/var/lib/mysql
datadir=/xxx/mydqldate/
#socket=/var/lib/mysql/mysql.sock
socket=/data/mydqldate/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default-character-set=utf8
lower_case_table_names=1
#skip-grant-tables

[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

时间: 2024-10-13 10:56:22

mysql root 维护的相关文章

MySQL root密码找回

以MySQL多实例为例,演示找回MySQL root的密码 1.关闭mysql服务 [[email protected] ~]# mysqladmin -uroot -poldboy123 -S /data/3306/mysql.sock shutdown ==>通过mysqladmin shutdown优雅关闭mysql服务. [[email protected] ~]# lsof -i:3306 2.使用--skip-grant-tables参数后台启动mysql,忽略授权验证直接登录 [[

mysql root密码忘记重置

1.修改/etc/my.cnf文件 找到mysqld选项,增加子项skip-grant-tables 2.重新启动mysql服务 service mysqld restart 3.进入mysql 在shell中执行mysql -u root 4.设置root新密码 update mysql.user set password=password('newpassword') where user='root'; flush privileges; 5.删除步骤1中进行的操作. 6.再次执行步骤2.

使用SKIP-GRANT-TABLES 解决 MYSQL ROOT密码丢失(转)

B.5.3.2 How to Reset the Root Password If you have never assigned a root password for MySQL, the server does not require a password at all for connecting as root. However, this is insecure. For instructions on assigning passwords, see Section 2.18.4,

mysql 'root'@'localhost'&‘root’@‘%’区别

1.%允许来自任何ip的连接 localhost允许本机的连接 2. dbfor studio mysql 6.2.280 %的情况,使用backup databases,倒出来的SQL文件,在另外一个数据库中导入(restore database)不进去 localhost的情况,使用backup databases,倒出来的SQL文件,在另外一个数据库中可以正常导入 3.  select * from mysql.proc可以看到他们的区别(procedure和function一样) db

[MySQL]如何修改mysql root密码

如何修改mysql root密码忘记MySQL ROOT密码是在MySQ使用中很常见的问题,可是有很多朋友并不会重置ROOT密码,那叫苦啊,特写此文章与大家交流: 1.编辑MySQL的配置文件:my.ini一般在MySQL安装目录下有my.ini即MySQL的配置文件.在此配置文件的最后添加如下一行:skip-grant-tables保存退出编辑. 2.然后重启MySQL服务在命令行下执行:net stop MySQLnet start MySQL 3.设置新的ROOT密码然后再在命令行下执行:

修改mysql root密码

mysql密码丢失后,在mysql命令行下执行如下命令,即可将root用户密码清空: mysqld_safe --skip-grant-tables&mysql修改密码 mysql修改,可在mysql命令行执行如下: mysql -u root mysql mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root'; mysql> FLUSH PRIVILEGES; mysql

Windows下修改mysql root用户密码

忘记mysql的root密码是一件让人头疼的问题. 下面理一下Windows7下面重置root密码的方法. 1.打开一个命令行窗口:这儿必须注意,要使用管理员身份打开: 2.关闭mysql服务:net stop mysql 3.运行 mysqld --skip-grant-tables.该命令是让mysql启动的时候跳过授权表,这儿要注意的是网上很多地方都是 mysqld-nt,但新版本已经被mysqld取代了. 4.重开一个命令行窗口(用管理员身份打开), 运行命令: mysql -u roo

MySQL 'root'@'localhost'无法登录

今天早上同事说MySQL root账号登录不上了.我试了一下 #mysql -u root -p 提示"Access denied for user 'root'@'localhost' (using password: YES)" 因为年后有同事离职,我第一反应是谁修改了root密码?按照忘记root密码来重置一下密码: #/etc/init.d/mysql stop #mysqld_safe –skip-grant-tables & #mysql -uroot -p mys

在windows环境下安装jdk,tomcat和mysql和可视化工具Navicat和安装tomcat,mysql服务让其自启,首次设置mysql root密码及忘记密码时的修改方法,亲测有用

1.安装jdk (1)下载jdk8,win64版本 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html (2)点击下载完的exe文件进行安装 选择jdk安装位置,我选择F:\environment\java\jdk. 选择jre安装位置,我选择F:\environment\java\jre. 等待安装完成,点击关闭. (3)配置环境变量 打开控制面板,点击高级系统设置,点