rhel5.1安装mysql后在终端运行mysql报错:
[root@localhost ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
第一次安装mysql,难道是我安装有问题?我是通过源码包编译安装的,于是我又下载最新的rpm包,通过rpm -ivh安装,还是不行。又通过yum进行安装。又直接重装系统,在选包的时候将“mysql服务器”选上,装完还是不行~~我晕~
今天上网一查,一位网友说:
“查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.
另外看看是不是权限问题.”
我按照此方法查看了下mysqld的状态。。。果然,是stop:(
[root@localhost ~]# /etc/rc.d/init.d/mysqld status
mysqld is stopped
赶紧启动一下mysqld,
[root@localhost ~]# /etc/rc.d/init.d/mysqld start
Initializing MySQL database:? Installing all prepared tables
Fill help tables
To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[? OK? ]
Starting MySQL:??????????????????????????????????????????? [? OK? ]
然后再试验运行mysql
[root@localhost ~]# mysql
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.22
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
额~~这样就好了。。。没启动mysql的守护进程导致的,service mysqld start下就好了。。。我竟然折腾到半夜。。。
另外,把其他几种可能也列出来:
[root@localhost ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
第一次安装mysql,难道是我安装有问题?我是通过源码包编译安装的,于是我又下载最新的rpm包,通过rpm -ivh安装,还是不行。又通过yum进行安装。又直接重装系统,在选包的时候将“mysql服务器”选上,装完还是不行~~我晕~
今天上网一查,一位网友说:
“查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.
另外看看是不是权限问题.”
我按照此方法查看了下mysqld的状态。。。果然,是stop:(
[root@localhost ~]# /etc/rc.d/init.d/mysqld status
mysqld is stopped
赶紧启动一下mysqld,
[root@localhost ~]# /etc/rc.d/init.d/mysqld start
Initializing MySQL database:? Installing all prepared tables
Fill help tables
To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[? OK? ]
Starting MySQL:??????????????????????????????????????????? [? OK? ]
然后再试验运行mysql
[root@localhost ~]# mysql
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.22
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
额~~这样就好了。。。没启动mysql的守护进程导致的,service mysqld start下就好了。。。我竟然折腾到半夜。。。
另外,把其他几种可能也列出来:
启动mysql 报错:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.
另外看看是不是权限问题.
2、确定你的mysql.sock是不是在那个位置,
mysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock
3、试试:service mysqld start
4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql
[root@localhost ~]# /etc/init.d/mysqld start
启动 MySQL: [ 确定 ]
[root@localhost ~]# mysql -uroot -p