MySQL資料庫安裝與啟動(Linux)

來源:互聯網
上載者:User

標籤:name   acl   listen   iat   title   rpo   host   evel   chkconfig   

1、用yum安裝

用root許可權開啟命令列介面,執行以下yum指令:

yum安裝MySQL
yum install mysql mysql-server mysql-devel -y

在最終提示Complete!表示安裝成功。

2、確認MySQL服務端已啟動

安裝完畢後,查看是否產生了mysqld服務——即MySQL的服務端。如果不是自動啟動的話,可以設定為自動啟動:

啟動服務端
[[email protected] ~]# chkconfig --list|grep mysqlmysqld          0:off   1:off   2:off   3:off   4:off   5:off   6:off[[email protected] ~]# chkconfig mysqld on[[email protected] ~]# chkconfig --list|grep mysqlmysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

也可以直接用service指令啟動服務。

3、MySQL目錄

通過yum安裝MySQL後,預設目錄為“/var/lib/mysql”,進入目錄:

MySQL目錄
[[email protected] mysql]# pwd/var/lib/mysql[[email protected] mysql]# lltotal 20488-rw-rw---- 1 mysql mysql 10485760 Jul 13 06:21 ibdata1-rw-rw---- 1 mysql mysql  5242880 Jul 13 06:21 ib_logfile0-rw-rw---- 1 mysql mysql  5242880 Jul 13 06:21 ib_logfile1drwx------ 2 mysql mysql     4096 Jul 13 06:21 mysqlsrwxrwxrwx 1 mysql mysql        0 Jul 13 06:21 mysql.sockdrwx------ 2 mysql mysql     4096 Jul 13 06:21 test

發現有兩個庫,都是mysql預設內建的。

4、查看連接埠 連接埠
[[email protected] mysql]# netstat -nultp|grep mysqltcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      15086/mysqld

MySQL預設佔用3306連接埠

5、命令列串連MySQL

直接執行,yum安裝的mysql,本地root密碼預設為空白。

串連MySQL
[[email protected] mysql]# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.1.71 Source distribution  Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.  Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.  Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.  mysql>
6、設定初始密碼和許可權

設定新密碼並授予許可權,重新整理許可權使之生效:(例密碼設定為“123456”)

設定許可權
mysql> grant all on *.* to [email protected]‘%‘ identified by ‘123456‘;Query OK, 0 rows affected (0.00 sec)  mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)  mysql> exit;Bye

MySQL資料庫安裝與啟動(Linux)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.