hi all when I am writing
mysql -u root
i am getting :
ERROR 2002 (HY000): Can't connect to local MySQL server through soc开发者_运维问答ket '/var/run/mysqld/mysqld.sock' (2)
what to do next ?I am in ubuntu.
a number of things could be wrong - mysqld could be down, it could have permissions issues, or there could be an issue with your bind-address or network loopback.
To figure out which of these might be the issue, can you try running:
sudo /etc/init.d/mysql restart
and post if you get any errors (depending on your machine, that might also tell you to run:
sudo service mysql restart
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
if you are new to installing mysql server you might probably face this error quite often if you type mysql in the shell prompt.
mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
To fix:
First start the mysql daemon, then type mysql
/etc/init.d/mysqld start mysql
Bingo! It worked for me!
To update mysql root password
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;
To add a new user to mysql
- First login as root then create a database ‘demo’
mysql -u root -p
Enter password:
mysql> create database demo;
After that create a new user named ‘guest’ with password ‘guest’ with all previleges assigned to demo database;
mysql> GRANT ALL PRIVILEGES ON mytest.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
Then exit mysql and connect through username guest; That should work!
精彩评论