#rpm –qa|grep –i mysql查看已安裝的mysql版本
如果有已存在的mysql版本則刪除
安裝服務端和用戶端,去Oracle官網下載:
# rpm -ivh MySQL-server-5.5.28-1.linux2.6.i386.rpm
# rpm -ivh MySQL-client-5.5.28-1.linux2.6.i386.rpm
安裝後會出現以下資訊,提示不要忘記設計root使用者的密碼以及其他資訊。
之後查看mysql的服務是否啟動#netstat -nat
如看到有3306的連接埠號碼,就說明服務啟動了,預設的連接埠是3306 ,如果沒有啟動的話 ,就開啟服務 #service mysql start 啟動mysql服務。
然後再輸入mysql,若出現以下提示資訊,說明成功。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
進入mysql資料庫後:mysql>use mysql;
然後查看一下root的情況select user,password form user;
修改密碼update user set password=password(‘newpassword’)where user=’root’ and host=’root’ or host=’localhost’;
至此mysql是安裝成功了的。
但是遠端存取還是不行的,還有兩個地方,第一是資料庫設定,第二是防火牆。一般資料庫已經是可以直接連接成功的了。只是沒有ROOT許可權,如果連不上,像我這樣的,肯定是被防火牆擋住了。
資料庫的MYSQL表中控制的可來訪的許可權,因此我們要改一下它,這樣我們就有ROOT許可權了。