Mysql卸載 yum remove mysql mysql-server mysql-libs compat-mysql51 rm -rf /var/lib/mysql rm /etc/my.cnf 查看是否還有mysql軟件: rpm -qa|grep mysql 有的話繼續(xù)刪除
Mysql安裝 1>若本地沒有安裝包 可以考慮使用yum命令進(jìn)行下載 # yum -y install mysql-server # yum -y install php-mysql 2>安裝后,MySQL自動(dòng)啟動(dòng), 【linux教程】 ,默認(rèn)沒有用戶名和密碼,設(shè)置新密碼 # /usr/bin/mysqladmin -u root password 'aaaaaa' [root@luozhonghua ~]# /usr/bin/mysqladmin -u root password 'aaaaaa' /usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists! 解決: 2.1》/etc/rc.d/init.d/mysqld status 看看mysql是否已經(jīng)啟動(dòng) 3.2》service mysqld start 3>登錄MySQL > mysql -u root -p enter password:’aaaaaa’
4>賦權(quán)連接的主機(jī) #grant select,insert,update,delete on *.* to root@192.168.1.101 identified by 'aaaaaa' grant select,insert,update,delete on *.* to root@127.0.0.1 identified by 'aaaaaa';
#6>設(shè)置mysql開機(jī)自啟動(dòng) # vi /etc/rc.local 加入如下一行 #/usr/share/mysql/mysql.server start 7>重新啟動(dòng)MySQL # /etc/init.d/mysql restart service mysqld restart
8>測試;
[root@luozhonghua ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 3 Server version: 5.1.73 Source distribution
mysql> use xxx; Database changed mysql> show database -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near 'database' at line 1 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | | xxx | +--------------------+ 4 rows in set (0.01 sec)
mysql> create table dbtest ( -> id int , -> name varchar); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near ')' at line 3 mysql> create table dbtest ( -> id int, -> name varchar(10)); Query OK, 0 rows affected (0.07 sec)