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,下载完毕后上传到服务器上

[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 

并修改名称

[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目录中,将该文件夹下的所有子目录和子文件都修改为mysql

[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即可

[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目录,执行;

[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]# 

完毕!

转载于:https://my.oschina.net/u/2499632/blog/912898

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值