剛接觸linux在linux下安裝mysql,由於之前沒有經驗繞了好久,現在說幾個我在安裝中遇到的問題:
# rpm -qa|grep -i mysql
b.如有就會顯示:MySQL-client-5.5.25-1.rhel5
MySQL-server-5.5.25-1.rhel5
c.有就刪除:(先刪除client 再刪server)# rpm -ivh MySQL-server-5.5.25-1.rhel5.x86_64.rpm
如果成功會顯示
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
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 eBSM-Server2 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
# rpm -ivh MySQL-client-5.5.25-1.rhel5.x86_64.rpm
成功顯示:Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
# service mysql start
Starting MySQL.. [ OK ]
[root@eBSM-Server2 init.d]# service mysql start
Starting MySQL...The server quit without updating PID file (/var/lib/mysql/eBSM-Server2.pid). [FAILED]
解決方法:1.mv /var/lib/mysql /data,把安裝目錄就放到/data/mysql下了。
賦值權限:
chmod 777 -R /data/mysql/
2./etc/rc.d/init.d/mysql 修改數據文件路徑爲datadir=/data/mysql
3.拷貝配置文件到/etc目錄下,並命名爲my.cnf(必須名爲my.cnf)
cp/usr/share/mysql/my-medium.cnf /etc/my.cnf
注意:/usr/share/mysql/下有好幾個結尾爲cnf的文件,它們的作用分別是:
1.my-small.cnf是爲了小型數據庫而設計的。不應該把這個模型用於含有一些常用項目的數據庫。
RAM需求(256MB)明顯多得多的物理內存。由此可見,如果有那麼多RAM內存可以使用,自然可以在同一臺機器上運行其它服務。
所以在這種類型的系統上將需要至少1GB的RAM,以便它能夠同時處理操作系統與數據庫應用程序。 並訪問數據的用戶數量。隨着數據庫和用戶的不斷增加,數據庫的性能可能會發生變化。 |
[client]
password = root
port = 3306
socket = /data/mysql/mysql.sock
default-character-set=utf8
[mysqld]
port = 3306
socket = /data/mysql/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
character_set_server=utf8
collation-server=utf8_general_ci
lower_case_table_names=1
character_set_client=utf8
[mysql]
default-character-set = utf8
no-auto-rehash
[root@eBSM-Server2 /]# mysql -h localhost -u root
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
上面這一行是設置遠程連接爲任意IP沒設密碼的,按自己需求定.mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
退出:mysql> EXIT;
Bye
最後說一句,這個報錯情況看個人而定的,不是每一次報錯都是同一種解決方法,