Home>

1. Problem description:

The following message appears when creating the database in the mysql console:

mysql>create database python;

error 1044 (42000):access denied for user ""@"localhost" to database "python"

2. Solution:

Execute the following command to enter the console:

mysql --user=root -p

Enter the root user's password to enter the mysql console:

Create the database:

create database python;

Show all databases:

show databases;

as follows:

[email protected]:~ $mysql --user=root -p

enter password:

welcome to the mysql monitor. commands end with;or \ g.

your mysql connection id is 4

server version:5.6.17 mysql community server (gpl)

copyright (c) 2000, 2014, oracleand/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>create database python;

query ok, 1 row affected (0.00 sec)

mysql>show databases;

+ -------------------- +

database |

+ -------------------- +

| information_schema |

| mysql |

| performance_schema |

| python |

| test |

+ -------------------- +

5 rows in set (0.02 sec)

mysql>

3. Ok, the above method is not the best, But it is simple and feasible,enjoy it !!!

4. Method 4:

After logging in to mysql with a blank password these days, and then changing the default mysql password,This problem has occurred with mysql tables,Hint:error 1044 (42000):access denied for user ""@"localhost" to database "mysql". I found some methods online,Finally done.

I use mysql integrated with xampp. I can log in to phpmyadmin with an empty password before, but I can't get into the phpmyadmin system table

Later, the solution was found to be successful because the user table in the mysql database has an account with an empty user name, that is, an anonymous account.As a result, although you are logged in as root, you are actually logged in anonymously.You can see it by ""@"localhost" in the error prompt.I solved the problem with method one,

method one:

Add in the [mysqld] field of my.ini:

skip-grant-tables

Restart the mysql service. At this time, mysql does not need a password to log in to the database.

Then enter mysql

mysql>use mysql;

mysql>update user set password=password ("new password") where user="root";

mysql>flush privileges;

After running, remove the skip-grant-tables in my.ini and restart mysqld.

Modify mysql password method two:

Restart the service without modifying my.ini,Run mysql with skip-grant-tables through non-service mode to change mysql password

Stop mysql service

Open a command line window,Start in the bin directory using mysqld-nt.exe, that is, execute in the command line window:mysqld-nt --skip-grant-tables

Then open another command line window,Log in to mysql without entering the mysql password.

After changing the password as above,Close the window running mysql from the command line,At this point, mysql is closed. If you find that mysql is still running, you can end the corresponding process to close it.

Start the mysql service.

Processing method under Linux:

mysql>use mysql
error 1044 (42000):access denied for user "root"@"localhost" to database "mysql"
mysql>exit
bye
[[email protected] ~] #service mysqld stop
stopping mysqld:[ok]
[[email protected] ~] #mysqld_safe --user=mysql --skip-grant-tables --skip-networking&
[[email protected] ~] #mysql -u root -p -hlocalhost
enter password:
mysql>use mysql
mysql>select host, user, password, grant_priv, super_priv from mysql.user;
mysql>update mysql.user set grant_priv="y", super_priv="y" where user="root";
mysql>flush privileges;
mysql>grant all on *. * to "root"@"localhost";
mysql>grant all on *. * to "root"@"cn.cn.cn.cn";
mysql>grant all on *. * to "root"@"245.245.245.245";
mysql>grant all on *. * to "root"@"127.0.0.1";
mysql>flush privileges;
mysql>quit
bye
[[email protected] ~] #service mysqld start
restart linux/os
  • Previous Detailed knowledge of the use of class templates in C ++ programming
  • Next How to install mysql55 in centos 7