Linux 下用yum安裝mysql

一、    查看系統自帶mysql是否已安裝。mysql

[root@develop  bin]# yum list installed | grep mysqllinux

mysql-libs.x86_64       5.1.73-5.el6_6  @base  sql

二、    如有自帶安裝的mysql,將其卸載數據庫

[root@develop  ~]# yum –y remove mysql-libs.x86_64centos

如有多個依賴文件則依次卸載。服務器

三、    使用yum安裝mysql數據庫。ide

[root@develop  ~]# yum -y install mysql-server mysql mysql-develui

命令將:mysql-server、mysql、mysql-devel都安裝好,當結果顯示爲「Complete!」即安裝完畢。spa

注:安裝mysql只是安裝了數據庫,只有安裝mysql-server才至關於安裝了客戶端。.net

四、    啓動mysql服務,在終端輸入:

service mysqld start或者/etc/init.d/mysqld start

五、    設置MySQL服務隨系統啓動自啓動

[root@develop  ~]# chkconfig mysqld on 

檢查啓動狀態

[root@develop ~]# chkconfig --list mysqld 

mysqld         0:關閉1:關閉2:啓用3:啓用4:啓用5:啓用6:關閉

六、    查看剛安裝mysql數據庫版本信息

[root@develop ~]# rpm -qi mysql-server

  1. Name        : mysql-server                 Relocations: (not relocatable)

  2. Version     : 5.1.73                            Vendor: CentOS

  3. Release     : 5.el6_6                       Build Date: 2015年06月22日 星期一 21時08分32秒

  4. Install Date: 2015年12月23日 星期三 11時00分00秒      Build Host: c6b9.bsys.dev.centos.org

  5. Group       : Applications/Databases        Source RPM: mysql-5.1.73-5.el6_6.src.rpm

  6. Size        : 25882979                         License: GPLv2 with exceptions

  7. Signature   : RSA/SHA1, 2015年06月22日 星期一 22時30分08秒, Key ID 0946fca2c105b9de

  8. Packager    : CentOS BuildSystem <http://bugs.centos.org>

  9. URL         : http://www.mysql.com

  10. Summary     : The MySQL server and related files

  11. Description :

  12. MySQL is a multi-user, multi-threaded SQL database server. MySQL is a

  13. client/server implementation consisting of a server daemon (mysqld)

  14. and many different client programs and libraries. This package contains

  15. the MySQL server and some accompanying files and directories.

七、    建立root管理用戶

查看文件安裝路徑

[root@develop ~]# whereis mysql

mysql: /usr/bin/mysql /usr/lib64/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

在終端輸入:cd /usr/bin/ 目錄下 建立root用戶密碼

[root@develop bin]# mysqladmin -u root -p password 密碼

八、    登陸mysql系統

[root@develop bin]# mysql -uroot -p

Enter password: [輸入原來密碼]

  1. Welcome to the MySQL monitor.  Commands end with ; or \g.

  2. Your MySQL connection id is 23

  3. Server version: 5.1.73 Source distribution

  4. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

  5. Oracle is a registered trademark of Oracle Corporation and/or its

  6. affiliates. Other names may be trademarks of their respective

  7. owners.

  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  9. mysql>

 九、建立遠程用戶

 使用grant語句添加:首先在數據庫本機上用root用戶

登陸mysql(我是用遠程控制linux服務器,至關於在服務器本機登陸mysql了),而後輸入:

mysql>grant all privileges on *.* to admin@localhost identified by 'something' with grant option;

添加一個用戶admin並受權經過本地機(localhost)訪問,密碼"something"。

 mysql>grant all privileges on *.* to admin@"%" identified by 'something' with grant option;

添加一個用戶admin並受權可從任何其它主機發起的訪問(通配符%)。使用這一條語句便可。

相關文章
相關標籤/搜索