linux下安裝rpm格式的mysql

來源:互聯網
上載者:User

標籤:

1.下載安裝包
官網下載.rpm格式安裝包,需要下面兩個檔案:
MySQL-server-5.0.26-0.i386.rpm   
MySQL-client-5.0.26-0.i386.rpm
註:官網下載時,如果選擇linux generic版本,而網頁沒有跳轉到相應的安裝包下載頁面,請到鏡像網站下載,可百度搜狐鏡像.

2.檢查是否已經安裝
[[email protected] ~]# rpm -qa | grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
說明已經安裝了庫檔案,應該先卸載,不然會出現覆蓋錯誤。
[[email protected] ~]# rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64

3.安裝MySQL服務端
在有兩個rmp檔案的目錄下運行如下命令:
[[email protected] ~]#rpm -ivh MySQL-server-5.5.29-2.el6.x86_64.rpm
安裝完成後,會在linux中自動添加一個mysql組,以及屬於mysql組的使用者mysql,可通過id命令查看。
[[email protected] ~]# id mysql
uid=496(mysql) gid=493(mysql) groups=493(mysql)
MySQL伺服器安裝之後雖然配置了相關檔案,但並沒有自動啟動mysql服務,需要手動啟動。
@tianxia ~]# service mysql start
Starting MySQL..........................................   [  OK  ]
註:安裝服務端時,安裝進程資訊中會顯示初始的隨機密碼在哪個檔案下

3.安裝MySQL用戶端
[[email protected] ~]#rpm -ivh MySQL-client-5.5.29-2.el6.x86_64.rpm
如果安裝成功就可以登陸MySql,命令是mysql,mysql 的使用文法如下:
mysql [-u username] [-h host] [-p[password]] [dbname]
username 與 password 分別是 MySQL 的使用者名稱與密碼,mysql的初始管理帳號是root,沒有密碼
註:這個root使用者不是Linux的系統使用者。MySQL預設使用者是root,第一次進時只需鍵入mysql即可(好像第一次不用輸入密碼,如果需要的話,vi初始隨機密碼所在的檔案)
[email protected] ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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>

4.linux下mysql修改root密碼(這裡的root是mysql預設使用者)
方法一:用set password命令
首先登入mysql
mysql -u root -p
然後執行set password命令
set password for [email protected] = password(‘123456‘);

方法二:使用mysqladmin
格式:mysqladmin -u root -p password 新密碼
mysqladmin -u root -p password 654321
此時會提示輸入舊密碼,輸入之後即可完成修改密碼

方法三:更改mysql的user表
首先登入mysql
mysql  -u root -p
然後操作mysql庫的user表,進行update
mysql> use mysql;
mysql> update use set password=password(‘123456‘) where user=‘root‘ and host=‘localhost‘
mysql> flush privileges;

方法四:忘記密碼的情況下
首先停止mysql服務
service mysql stop
以跳過授權的方式啟動mysql
mysqld_safe
以root使用者登入mysql
mysql -u root
操作mysql庫的user表,進行update
mysql> use mysql;
mysql> update user set password=password(‘123456‘) where user=‘root‘ and host=‘localhost‘
mysql> flush privileges;
mysql> quit
重啟mysql服務
service mysql restart

linux下安裝rpm格式的mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.