Linux environment. The location of all databases and user information can be viewed in (VIM/ETC/MY.CNF) [Datadir=/usr/local/mysql_data].
Cannot read the database information (reason: The permission has also changed during the move DataDir [Chown mysql:mysql-r DataDir]), DataDir is your storage path.
The code is as follows |
Copy Code |
ERROR 2002 (HY000): Can ' t connect to the local MySQL server through socket '/var/lib/mysql/mysql.sock ' |
(2), workaround [see if the file exists. Modify the appropriate path vim/etc/my.cnf to see if the permissions are not right. Ls-l].
The code is as follows |
Copy Code |
ERROR 2002 (HY000): Can ' t connect to the local MySQL server through socket '/var/lib/mysql/mysql.sock ' |
(111), the workaround [modify the corresponding path VIM/ETC/MY.CNF]
Add the following paragraph:
The code is as follows |
Copy Code |
Port = 3306 Socket =/var/lib/mysql_data/mysql.sock |
MySQL data table in use, error tip: "Martin" is marked as crashed and should are repaired
Workaround:
Go to MySQL's data directory and execute at the command line: Myisamchk-c-R Martin. Myi
MySQL allows remote connection method: When adding a MySQL user, the host option is changed to "%" on it.
MySQL problems will be added to the future.
other methods on the network
The problem is finally resolved:
Methods: Modify/etc/my.conf:
The code is as follows |
Copy Code |
[Mysqld] Datadir=/usr/local/mysql/data Socket=/var/lib/mysql/mysql.sock [Mysql.server] User=mysql Basedir=/usr/local/mysql If There is isn't currently a section called [Client], add one at the bottom of the "File and copy" socket= line under the [MYSQLD] section such as: [Client] Socket=/var/lib/mysql/mysql.sock |
The discovery remains the same, running/etc/init.d/mysql start
Error: Starting MYSQLCOULDN ' t find MySQL Manager or server
MYSQLD Service is not open, run
The code is as follows |
Copy Code |
/usr/local/mysql/bin/mysqld_safe |
The problem is solved.
A little solution to the official website
If you are are new to installing MySQL server your might probably face this error quite often if your type MySQL in the shell PR Ompt.
The code is as follows |
Copy Code |
> mysql ERROR 2002 (HY000): Can ' t connect to the local MySQL server through socket '/var/lib/mysql/mysql.sock ' |
To fix:
Start the MySQL daemon, then type MySQL
The code is as follows |
Copy Code |
>/etc/init.d/mysqld Start > mysql |
Bingo! It worked for me!
To update MySQL root password
The code is as follows |
Copy Code |
mysql> use MySQL; mysql> UPDATE user SET Password=password (' New-password ') WHERE user= ' root '; mysql> FLUSH privileges; |
To add a new user to MySQL
1. As root then create a database ' demo '
> Mysql-u root-p
The code is as follows |
Copy Code |
Enter Password: Mysql> CREATE DATABASE demo; |
After this create a new user named ' Guest ' with password ' guest ' and all Previleges assigned to demo database;
The code is as follows |
Copy Code |
Mysql> grant all privileges in mytest.* to ' guest ' @ ' localhost ' identified by ' guest ' with GRANT OPTION; |
Then exit MySQL and connect through username guest;
That should work!
Note:this could happen, if you run out of the your disk space. Check your disk space.