linux下安裝mysql(rpm文件安裝)

數據庫包下載:

https://www.mysql.com/downloads/

在GPL開原協議的社區開源版裏邊下載

 

 

咱們用mysql community server裏邊的

 

 

 

 

其中workbench是客戶端工具mysql

 

 

MySQL Cluster是oracle本身搞的集羣版的(集成了一些開源工具和增值服務)linux

 

 

 

選擇操做系統和版本

建議在linux下安裝web

 

 

也能夠選擇版本

 

 

下載server包和client包

若是是server包,那架構圖裏的東西都有了sql

還要下個client utilities包,客戶端包,相似connection層shell

 

 

 

 

下載後用rz命令傳到centos linux系統裏邊

rpm是包管理器數據庫

xshell能夠直接拖bootstrap

也能夠用rz命令,沒有的話安裝一下: yum install lrzszcentos

yum是包資源管理器,能夠解決包依賴的問題,把須要的包都下載下來架構

傳到linux系統oracle

 

 

安裝mysql步驟:

清理環境

centos7會自帶一個mariadb

查看是否已安裝

rpm -qa |grep -i mysql

rpm -qa |grep -i mariadb(centos7默認系統自帶的)

 

mariadb是從mysql來的,是它的一個分支,須要清理掉

清理掉mariadb包

用yum直接安裝你的話,用的mariadb的yum源,它跟mysql官方正式版不太同樣,咱們要安裝官方正式版,就須要清掉mariadb,而後手動安裝本身下載的官方正式版mysql

rpm -e 加上包名,把mariadb包清掉

能夠看到用rpm刪除會失敗,提示有依賴關係的軟件須要安裝

rpm -e mariadb-libs-5.5.56-2.el7.x86_64

 

rpm刪除時若是有依賴關係,能夠用yum remove + 包名來刪除mariadb

 

開始安裝:

通常用裝軟件用yum直接安裝也能夠,可是有一個問題:用yum的話,是到默認的mariadb用的yum源去找,可能會找不到,因此咱們本身來安裝

 

rpm –ivh + 包安裝所須要的包

rpm -ivh MySQL-client-5.6.42-1.el7.x86_64.rpm

 

 

rpm -ivh MySQL-server-5.6.42-1.el7.x86_64.rpm

 

 

server安裝成功後會輸出一些信息,以下:

[root@localhost soft]# rpm -ivh MySQL-server-5.6.42-1.el7.x86_64.rpm

warning: MySQL-server-5.6.42-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:MySQL-server-5.6.42-1.el7        ################################# [100%]

warning: user mysql does not exist - using root

warning: group mysql does not exist - using root

warning: user mysql does not exist - using root

warning: group mysql does not exist - using root

2018-11-18 13:53:24 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2018-11-18 13:53:24 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.

2018-11-18 13:53:24 0 [Note] /usr/sbin/mysqld (mysqld 5.6.42) starting as process 6420 ...

2018-11-18 13:53:24 6420 [Note] InnoDB: Using atomics to ref count buffer pool pages

2018-11-18 13:53:24 6420 [Note] InnoDB: The InnoDB memory heap is disabled

2018-11-18 13:53:24 6420 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2018-11-18 13:53:24 6420 [Note] InnoDB: Memory barrier is not used

2018-11-18 13:53:24 6420 [Note] InnoDB: Compressed tables use zlib 1.2.11

2018-11-18 13:53:24 6420 [Note] InnoDB: Using Linux native AIO

2018-11-18 13:53:24 6420 [Note] InnoDB: Using CPU crc32 instructions

2018-11-18 13:53:24 6420 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2018-11-18 13:53:24 6420 [Note] InnoDB: Completed initialization of buffer pool

2018-11-18 13:53:24 6420 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

2018-11-18 13:53:24 6420 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

2018-11-18 13:53:24 6420 [Note] InnoDB: Database physically writes the file full: wait...

2018-11-18 13:53:24 6420 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

2018-11-18 13:53:25 6420 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

2018-11-18 13:53:25 6420 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

2018-11-18 13:53:25 6420 [Warning] InnoDB: New log files created, LSN=45781

2018-11-18 13:53:25 6420 [Note] InnoDB: Doublewrite buffer not found: creating new

2018-11-18 13:53:25 6420 [Note] InnoDB: Doublewrite buffer created

2018-11-18 13:53:25 6420 [Note] InnoDB: 128 rollback segment(s) are active.

2018-11-18 13:53:25 6420 [Warning] InnoDB: Creating foreign key constraint system tables.

2018-11-18 13:53:25 6420 [Note] InnoDB: Foreign key constraint system tables created

2018-11-18 13:53:25 6420 [Note] InnoDB: Creating tablespace and datafile system tables.

2018-11-18 13:53:25 6420 [Note] InnoDB: Tablespace and datafile system tables created.

2018-11-18 13:53:25 6420 [Note] InnoDB: Waiting for purge to start

2018-11-18 13:53:25 6420 [Note] InnoDB: 5.6.42 started; log sequence number 0

A random root password has been set. You will find it in '/root/.mysql_secret'.

2018-11-18 13:53:26 6420 [Note] Binlog end

2018-11-18 13:53:26 6420 [Note] InnoDB: FTS optimize thread exiting.

2018-11-18 13:53:26 6420 [Note] InnoDB: Starting shutdown...

2018-11-18 13:53:27 6420 [Note] InnoDB: Shutdown completed; log sequence number 1625977

 

 

2018-11-18 13:53:27 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2018-11-18 13:53:27 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.

2018-11-18 13:53:27 0 [Note] /usr/sbin/mysqld (mysqld 5.6.42) starting as process 6444 ...

2018-11-18 13:53:27 6444 [Note] InnoDB: Using atomics to ref count buffer pool pages

2018-11-18 13:53:27 6444 [Note] InnoDB: The InnoDB memory heap is disabled

2018-11-18 13:53:27 6444 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2018-11-18 13:53:27 6444 [Note] InnoDB: Memory barrier is not used

2018-11-18 13:53:27 6444 [Note] InnoDB: Compressed tables use zlib 1.2.11

2018-11-18 13:53:27 6444 [Note] InnoDB: Using Linux native AIO

2018-11-18 13:53:27 6444 [Note] InnoDB: Using CPU crc32 instructions

2018-11-18 13:53:27 6444 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2018-11-18 13:53:27 6444 [Note] InnoDB: Completed initialization of buffer pool

2018-11-18 13:53:27 6444 [Note] InnoDB: Highest supported file format is Barracuda.

2018-11-18 13:53:27 6444 [Note] InnoDB: 128 rollback segment(s) are active.

2018-11-18 13:53:27 6444 [Note] InnoDB: Waiting for purge to start

2018-11-18 13:53:27 6444 [Note] InnoDB: 5.6.42 started; log sequence number 1625977

2018-11-18 13:53:27 6444 [Note] Binlog end

2018-11-18 13:53:27 6444 [Note] InnoDB: FTS optimize thread exiting.

2018-11-18 13:53:27 6444 [Note] InnoDB: Starting shutdown...

2018-11-18 13:53:29 6444 [Note] InnoDB: Shutdown completed; log sequence number 1625987

 

 

 

 

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in '/root/.mysql_secret'.

 

You must change that password on your first connect,

no other statement but 'SET PASSWORD' will be accepted.

See the manual for the semantics of the 'password expired' flag.

 

Also, the account for the anonymous user has been removed.

 

In addition, you can run:

 

  /usr/bin/mysql_secure_installation

 

which will also give you the option of removing the test database.

This is strongly recommended for production servers.

 

See the manual for more instructions.

 

Please report any problems at http://bugs.mysql.com/

 

The latest information about MySQL is available on the web at

 

  http://www.mysql.com

 

Support MySQL by buying support/licenses at http://shop.mysql.com

 

WARNING: Found existing config file /usr/my.cnf on the system.

Because this file might be in use, it was not replaced,

but was used in bootstrap (unless you used --defaults-file)

and when you later start the server.

The new default config file was created as /usr/my-new.cnf,

please compare it with your file and take the changes you need.

其中有兩句指明mysql安裝時給root設置了一個隨機的初始密碼:

密碼的位置放在'/root/.mysql_secret'文件中

用於第一次登錄mysql時使用的,登錄以後會強制修改一下

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,

no other statement but 'SET PASSWORD' will be accepted.

See the manual for the semantics of the 'password expired' flag.

 

查看該文件,能夠看到我在重裝mysql時新生成一個隨機密碼

 

 

ps –ef|grep –i mysql 看是否有mysql進程

 

 

用rpm –qa |grep –I mysql看下mysql是否安裝成功了,看到兩個mysql的組件,就是安裝成功了

 

 

5.6之後要設置一個root帳號的隨機密碼

密碼保存到root/.mysql_secret文件裏

 

 

後邊須要用這個初始的密碼登陸mysql

啓動服務:service mysql start

 

ps –ef |grep mysql 看有沒有mysql服務

 

登陸數據庫:

mysql –uroot –p 敲回車

而後輸入隨機密碼

登陸後,提示一些信息

 

 

如鏈接線程id、版本什麼的

show databases; 查看數據庫有哪些庫

在使用前要設置一個本身的密碼

會要求重置隨機密碼

 

 

重置密碼方法:set password=password(‘root’);

是給當前用戶設置密碼爲root

 

再運行 show databases;

mysql會自帶一些系統庫:

information_schema存一些統計數據

performance_schema存一些狀態數據,

mysql存的數據用於監控、權限、帳號等

test是測試庫,用於作測試用的

 

若是從新安裝,數據目錄沒變的話,那麼以前的庫仍是存在的

相關文章
相關標籤/搜索