安装的版本:
MySQL-server-5.5.32-2.linux2.6.i386.rpm
MySQL-client-5.5.32-2.linux2.6.i386.rpm
//卸载与安装前先查看已安装的包
# rpm -qa | grep -i mysql
MySQL-server-5.0.22-0.i386
MySQL-client-5.0.22-0.i386
//卸载
# rpm -ev MySQL-server-5.0.22-0.i386
# rpm -ev MySQL-client-5.0.22-0.i386
//安装
# rpm -ivh MySQL-server-5.5.32-2.linux2.6.i386.rpm
# rpm -ivh MySQL-client-5.5.32-2.linux2.6.i386.rpm
//如若安装不了,选择强制安装
# rpm -ivh --force MySQL-server-5.5.32-2.linux2.6.i386.rpm
# rpm -ivh --force MySQL-client-5.5.32-2.linux2.6.i386.rpm
//拷贝my-medium.cnf配置文件并修改为my.cnf
# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
//启动
# service mysql start
问题一:进入mysql工具时,总是有错误提示:
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
或者
# mysql -u root -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
解决办法,如下:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'
and host='root' or host='localhost';//把空的用户密码都修改成非空的密码就行了。
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
这样就进去mysql了
问题二:在上面mysql里面一刷新权限,结果报错,说mysql.servers表不存在
mysql> flush privileges;
ERROR 1146 (42S02): Table 'mysql.servers' doesn't exist
解决办法:
既然不存在那就创建一个,当然要先use mysql 才行,不然直接创建会报错。
mysql> USE mysql;
mysql> CREATE TABLE `servers` (
-> `Server_name` CHAR(64) NOT NULL,
-> `Host` CHAR(64) NOT NULL,
-> `Db` CHAR(64) NOT NULL,
-> `Username` CHAR(64) NOT NULL,
-> `Password` CHAR(64) NOT NULL,
-> `Port` INT(4) DEFAULT NULL,
-> `Socket` CHAR(64) DEFAULT NULL,
-> `Wrapper` CHAR(64) NOT NULL,
-> `Owner` CHAR(64) NOT NULL,
-> PRIMARY KEY (`Server_name`)
-> ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers
table';
Query OK, 0 rows affected (0.01 sec)
这样,问题就解决了
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
问题三:mysql 启动错误-server PID file could not be found
ERROR! MySQL server PID file could not be found!
解决办法:
首先查看一下进程 # ps aux |grep mysq*
root 1632 0.0 0.0 5128 1408 ? S Jul15 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 1755 0.0 1.0 322092 34400 ? Sl Jul15 1:08 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --
user=mysql --log-error=/var/lib/mysql/localhost.localdomain.err --pid-
file=/var/lib/mysql/localhost.localdomain.pid
root 11853 0.0 0.0 6908 1460 pts/3 T 01:22 0:00 /bin/sh /sbin/service mysql restart
root 11858 0.0 0.0 3044 1188 pts/3 T 01:22 0:00 /bin/sh /etc/init.d/mysql restart
root 11870 0.0 0.0 3048 1224 pts/3 T 01:22 0:00 /bin/sh /etc/init.d/mysql start
root 11876 0.0 0.0 3048 1276 pts/3 T 01:22 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 11967 0.0 0.0 0 0 pts/3 Z 01:22 0:00 [mysqld] <defunct>
root 12093 0.0 0.0 6680 1180 pts/3 T 01:23 0:00 /bin/sh /etc/init.d/mysql restart
root 12105 0.0 0.0 6684 1212 pts/3 T 01:23 0:00 /bin/sh /etc/init.d/mysql start
root 12111 0.0 0.0 6684 1276 pts/3 T 01:23 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 12202 0.0 0.0 0 0 pts/3 Z 01:23 0:00 [mysqld] <defunct>
root 12317 0.0 0.0 6680 1180 pts/3 T 01:24 0:00 /bin/sh /etc/init.d/mysql restart
root 12329 0.0 0.0 6684 1212 pts/3 T 01:24 0:00 /bin/sh /etc/init.d/mysql start
root 12335 0.0 0.0 6684 1272 pts/3 T 01:24 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 12600 0.0 0.0 0 0 pts/3 Z 01:24 0:00 [mysqld] <defunct>
root 12622 0.0 0.0 6908 1464 pts/3 T 01:24 0:00 /bin/sh /sbin/service mysql restart
root 12627 0.0 0.0 3044 1192 pts/3 T 01:24 0:00 /bin/sh /etc/init.d/mysql restart
root 12639 0.0 0.0 3048 1224 pts/3 T 01:24 0:00 /bin/sh /etc/init.d/mysql start
root 12645 0.0 0.0 3048 1276 pts/3 T 01:24 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 12910 0.0 0.0 0 0 pts/3 Z 01:24 0:00 [mysqld] <defunct>
root 13561 0.0 0.0 6684 1212 pts/3 T 01:33 0:00 /bin/sh /etc/init.d/mysql start
root 13567 0.0 0.0 6684 1368 pts/3 T 01:33 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 13832 0.0 0.0 0 0 pts/3 Z 01:33 0:00 [mysqld] <defunct>
root 13953 0.0 0.0 6684 1216 pts/3 T 01:34 0:00 /bin/sh /etc/init.d/mysql start
root 13959 0.0 0.0 6684 1272 pts/3 T 01:34 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 14224 0.0 0.0 0 0 pts/3 Z 01:34 0:00 [mysqld] <defunct>
root 14380 0.0 0.0 5984 764 pts/3 S+ 01:50 0:00 grep mysq*
如果看到上面的内容,那说明,Mysql的进程卡死了,这时用就要把这些卡死的进程都关闭
[root@localhost ~]# kill 1632
[root@localhost ~]# kill 1755
启动Mysql就ok了
# service mysql start
Starting MySQL. [ OK ]