ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'meitu'
mysql
安装好mysql后,root用户帐户登陆mysql,建立一个新数据库时,提示报错,以下:sql
[root@localhost mysql]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.6.48 MySQL Community Server (GPL) Copyright (c) 2000, 2019, 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | +--------------------+ 1 row in set (0.00 sec) mysql> create database meitu charset=utf8; ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'meitu'
[maaiqiang@localhost ~]$ systemctl restart mysqld
这时的mysql不须要密码便可登陆数据库数据库
mysql > use mysql; mysql > delete from user where USER=''; mysql > flush privileges; mysql > exit;