解决方法:
利用mysql安装时的默认用户名登录mysql后, 输入以下命令修改root密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
2. 授予用户权限
GRANT ALL PRIVILEGES ON *.* TO 'jiang'@'%' IDENTIFIED BY '1';
flush privileges;
下面的内容没有用到
一.有时可以直接输入命令: mysql进入数据库
启动数据库:# mysqld_safe &
二.查看用户命令:
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> select host,user from mysql.user;//show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
rows in set (0.00 sec) mysql>
删除用户
mysql>Delete FROM user Where User='test' and Host='localhost'; mysql>flush privileges; mysql>drop database testDB; //删除用户的数据库 删除账户及权限:>drop user 用户名@'%'; >drop user 用户名@ localhost;
创建用户
mysql> create user 'root'@'%' identified by '';# %代表所有端口
Query OK, rows affected (0.07 sec) mysql> select host,user from mysql.user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| % | usrabc |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+------------------+
rows in set (0.00 sec)
查看数据库列表:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
row in set (0.00 sec) mysql>