redhat 7.3下mysql版本5.5.56安裝-單點模式

下載安裝包

本文是選擇使用mysql的community-server版本安裝,版本號:mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz,下載地址:https://dev.mysql.com/downloads/mysql/5.5.html#downloads,下載完畢後上傳到服務器上html

[root@localhost hadmin]# ll
total 187264
-rw-r--r--. 1 root root 191754676 Jun  1 03:54 mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
[root@localhost hadmin]# 

安裝包解壓

[root@localhost hadmin]# tar zxvf mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz

並修更名稱node

[root@localhost hadmin]# mv mysql-5.5.56-linux-glibc2.5-x86_64 mysql

將文件夾剪切到/usr/local下

[root@localhost hadmin]# mv mysql /usr/local/

添加mysql用戶和用戶組

[root@localhost local]# groupadd mysql
[root@localhost local]# useradd -r -g mysql mysql
[root@localhost local]#

修改文件夾的所屬用戶和用戶組

[root@localhost local]# chown mysql:mysql mysql
[root@localhost local]# ll
total 0
drwxr-xr-x.  2 root  root  106 Jun  1 11:21 bin
drwxr-xr-x.  2 root  root    6 Mar 10  2016 etc
drwxr-xr-x.  2 root  root    6 Mar 10  2016 games
drwxr-xr-x.  2 root  root    6 Mar 10  2016 include
drwxr-xr-x.  2 root  root    6 Mar 10  2016 lib
drwxr-xr-x.  2 root  root    6 Mar 10  2016 lib64
drwxr-xr-x.  2 root  root    6 Mar 10  2016 libexec
drwxr-xr-x. 13 mysql mysql 213 Jun  1 11:27 mysql
drwxr-xr-x.  2 root  root    6 Mar 10  2016 sbin
drwxr-xr-x.  6 root  root   60 Jun  1 11:21 share
drwxr-xr-x.  2 root  root    6 Mar 10  2016 src
[root@localhost local]#

進入到mysql目錄中,將該文件夾下的全部子目錄和子文件都修改成mysqlmysql

[root@localhost local]# cd mysql/
[root@localhost mysql]# chown mysql:mysql *
[root@localhost mysql]# chown mysql:mysql */*
[root@localhost mysql]# chown mysql:mysql */*/*
[root@localhost mysql]# chown mysql:mysql */*/*/*
[root@localhost mysql]# chown mysql:mysql */*/*/*/*
[root@localhost mysql]# chown mysql:mysql */*/*/*/*/*
[root@localhost mysql]# chown mysql:mysql */*/*/*/*/*/*
chown: cannot access ‘*/*/*/*/*/*/*’: No such file or directory
[root@localhost mysql]# ll
total 56
drwxr-xr-x.  2 mysql mysql  4096 Jun  1 11:27 bin
-rw-r--r--.  1 mysql mysql 17987 Apr 27 03:12 COPYING
drwxr-xr-x.  3 mysql mysql    18 Jun  1 11:26 data
drwxr-xr-x.  2 mysql mysql    55 Jun  1 11:27 docs
drwxr-xr-x.  3 mysql mysql  4096 Jun  1 11:26 include
-rw-r--r--.  1 mysql mysql   301 Apr 27 03:12 INSTALL-BINARY
drwxr-xr-x.  3 mysql mysql  4096 Jun  1 11:27 lib
drwxr-xr-x.  4 mysql mysql    30 Jun  1 11:26 man
drwxr-xr-x. 10 mysql mysql  4096 Jun  1 11:26 mysql-test
-rw-r--r--.  1 mysql mysql  2496 Apr 27 03:12 README
drwxr-xr-x.  2 mysql mysql    30 Jun  1 11:26 scripts
drwxr-xr-x. 27 mysql mysql  4096 Jun  1 11:26 share
drwxr-xr-x.  4 mysql mysql  4096 Jun  1 11:27 sql-bench
drwxr-xr-x.  2 mysql mysql  4096 Jun  1 11:26 support-files
[root@localhost mysql]#

複製啓動文件和my.cnf

[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ll
total 96
-rwxr-xr-x. 1 mysql mysql  1153 Apr 27 06:27 binary-configure
-rw-r--r--. 1 mysql mysql  4528 Apr 27 06:27 config.huge.ini
-rw-r--r--. 1 mysql mysql  2382 Apr 27 06:27 config.medium.ini
-rw-r--r--. 1 mysql mysql  1626 Apr 27 06:27 config.small.ini
-rw-r--r--. 1 mysql mysql   773 Apr 27 03:12 magic
-rw-r--r--. 1 mysql mysql  4691 Apr 27 06:27 my-huge.cnf
-rw-r--r--. 1 mysql mysql 19759 Apr 27 06:27 my-innodb-heavy-4G.cnf
-rw-r--r--. 1 mysql mysql  4665 Apr 27 06:27 my-large.cnf
-rw-r--r--. 1 mysql mysql  4676 Apr 27 06:27 my-medium.cnf
-rw-r--r--. 1 mysql mysql  2840 Apr 27 06:27 my-small.cnf
-rwxr-xr-x. 1 mysql mysql  1061 Apr 27 06:27 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql   839 Apr 27 06:27 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10565 Apr 27 06:27 mysql.server
-rw-r--r--. 1 mysql mysql  1326 Apr 27 06:27 ndb-config-2-node.ini
[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
[root@localhost support-files]# cp my-medium.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@localhost support-files]#

my.cnf配置一下數據庫的默認字符集utf8,將如下內容複製到my.cnf便可linux

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

註冊和初始化MySQL服務

進入到scripts目錄,執行;sql

[root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
[1] 40869
[root@localhost scripts]# Installing MySQL system tables...
170601 11:43:26 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
170601 11:43:26 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.56-log) starting as process 40905 ...
OK
Filling help tables...
170601 11:43:26 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
170601 11:43:26 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.56-log) starting as process 40912 ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/local/mysql/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.

You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

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


[1]+  Done                    ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[root@localhost scripts]#

啓動mysql和進入mysql

[root@localhost scripts]# /etc/init.d/mysql start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
. SUCCESS! 
[root@localhost scripts]#
[root@localhost bin]# ./mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.56-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> set password for root@localhost = password('123456');

爲了能全局使用mysql,須要創建一個軟鏈接,也能夠配置profile:數據庫

[root@localhost bin]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
[root@localhost bin]#

完畢!bootstrap

相關文章
相關標籤/搜索