《Mysql應用linux下mysql數據庫安裝與配置步驟》要點:
本文介紹了Mysql應用linux下mysql數據庫安裝與配置步驟,希望對您有用。如果有疑問,可以聯系我們。
導讀:一,首先,查看LINUX的版本
[root@jbxue mysql]# lsb_release -aLSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphic...
MYSQL必讀一,首先,查看LINUX的版本
?
[root@jbxue mysql]# lsb_release -a
LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch Distributor ID: RedHatEnterpriseServer Description: Red Hat Enterprise Linux Server release 5.2 (Tikanga) Release: 5.2 Codename: Tikanga
?
MYSQL必讀然后,去mysql官網http://dev.mysql.com/downloads/mysql/下載MySQL的相應版本的安裝文件.
一般情況下,下載兩個和linux系統相對應的mysql安裝文件即可.
MYSQL必讀分別是server和client版本.
?
http://downloads.mysql.com/archives.php?p=mysql-5.1&v=5.1.58
RedHat Enterprise Linux 5 RPM (AMD64, Client programs) (4 Jul 2011, 7.2M)
RedHat Enterprise Linux 5 RPM (AMD64, Server) (4 Jul 2011, 20.3M)
?
MYSQL必讀具體文件見二.
?
二,將下載后的對應的安裝文件放到linux下自定義的一個新建的文件夾mysql下.
使用命令安裝相應的rpm文件.
MYSQL必讀在mysql文件路徑下,輸入如下命令即可.
MYSQL必讀首先,安裝服務器端 :
?
[root@jbxue mysql]#rpm -ivh MySQL-server-community-5.1.58-1.rhel5.x86_64.rpm
MYSQL必讀其次,安裝客戶端 :
?
[root@jbxue mysql]#rpm -ivh MySQL-client-community-5.1.58-1.rhel5.x86_64.rpm
?
MYSQL必讀例如:
?
[root@jbxue software]# rpm -ivh MySQL-server-community-5.1.58-1.rhel5.x86_64.rpm?
Preparing...??????????????? ########################################### [100%]?
?? 1:MySQL-server-community ########################################### [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? 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!?
?
Starting MySQL..[è·?¨]?
Giving mysqld 2 seconds to start?
[root@jbxue software]# rpm -ivh MySQL-client-community-5.1.58-1.rhel5.x86_64.rpm?
Preparing...??????????????? ########################################### [100%]?
?? 1:MySQL-client-community ########################################### [100%]?
[root@jbxue software]#?
?
MYSQL必讀三,安裝完成后,
mysql安裝目錄可能在:/usr/bin/mysql?
mysql啟動文件可能在: /etc/rc.d/init.d/mysqld
使用whereis mysql命令來查找它安裝的路徑
使用命令 rpm -qal | grep mysql 確定linux下已安裝MYSQL的安裝路徑.
例如:
?
[root@jbxue mysql]# rpm -qal | grep mysql
?
//使用如下命令查看系統是否已經安裝mysql
[root@jbxue mysql]# rpm –qa | grep mysql
?
MYSQL必讀或鍵入命令:
?
[root@jbxue mysql]$ netstat -nat
tcp 0 0 127.0.0.1:3306 127.0.0.1:33648 ESTABLISHED tcp 0 0 127.0.0.1:3306 127.0.0.1:33649 ESTABLISHED
?
MYSQL必讀出現以上內容.
或直接敲入命令mysql+回車
?
[root@jbxue ~]$mysql Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 5136 Server version: 5.1.58-community MySQL Community Server (GPL) Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>
?
MYSQL必讀即表示linux下mysql安裝成功
MYSQL必讀第二部發,對已安裝完成的mysql,進行相應的配置
MySQL默認沒有暗碼,安裝完畢增加暗碼的重要性是不言而喻的.
1、命令
usr/bin/mysqladmin -u root password 'new-password'
格式:mysqladmin -u用戶名 -p舊暗碼 password 新暗碼
例:給root加個暗碼ysong.
鍵入以下命令 :
[root@jbxue ~]$ /usr/bin/mysqladmin -u root password ysong
注:因為開始時root沒有暗碼,所以-p舊暗碼一項就可以省略了.
?
此時,在敲入,即可訪問mysql
?
[root@jbxue ~]$ mysql -uroot -pysong
?
[ysong@IDC ~]$mysql -uroot -pysong Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 5159 Server version: 5.1.58-community MySQL Community Server (GPL) Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>
?
MYSQL必讀1、用命令啟動mysql
MySQL安裝完成后啟動文件mysql在/etc/init.d目錄下,在需要啟動時運行下面命令即可.
[root@jbxue ~]$sudo? /etc/init.d/mysql start
注:sudo運行,不然可能會報錯,權限原因;
?
[root@jbxue ~]$? /etc/init.d/mysql start
Starting MySQL.Manager of pid-file quit without updating file.[失敗]
?
MYSQL必讀2、用命令停止mysql
?
[root@jbxue ~]$ /usr/bin/mysqladmin -u root -pysong shutdown
?
MYSQL必讀1:創建用戶:
?
CREATE USER ' pig'@'% ' IDENTIFIED BY 'ysong';
[root@jbxue ~]$ mysql -uysong -psong
[root@jbxue ~]$ mysql -uroot -pysong
grant all privileges on e6mall.* to ysong@'%'
grant select,insert,alter,drop on e6mall.* to ysong@"%" identified by "song";
GRANT ALL PRIVILEGES ON e6mall.* TO ysong@"%" IDENTIFIED BY "song";
use mysql;
select user,password from user;
delete from user where user is NULL
update user set password='ysong' where user is 'ysong';
MYSQL必讀2:授權:
?
use mysql?
update user set password=password('mysql') where user='root';
update user set password=password('ysong') where user='ysong';
flush privileges;
?
MYSQL必讀最后,創建數據庫,導入數據庫sql文件.
?
mysql -uroot -pysong
create database e6mall;
mysql -uroot -pysong e6mall < /opt/mysql/e6mall.sql;
MYSQL必讀至此,就完成了linux下mysql數據庫的安裝與配置,希望對大家有所贊助.
維易PHP培訓學院每天發布《Mysql應用linux下mysql數據庫安裝與配置步驟》等實戰技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養人才。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/12741.html