2

mysql安装步骤(1)源码编译

 2 years ago
source link: https://wakzz.cn/2017/09/29/mysql/%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4(1)%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

一、准备文件

mysql-5.6.31.tar.gz
下载链接

yum install -y glibc.i686
yum install -y gcc gcc-c++
yum install -y cmake
yum install -y ncurses-devel
yum install -y bison
yum install -y perl perl-devel
yum install -y autoconf

1、解压源码包mysql-5.6.31.tar.gz

$ tar -zxvf mysql-5.6.31.tar.gz

2、设置参数,这一步需要自定义mysql的安装路径

$ mkdir /home/sun_zeming/mysql/mysql-3
$ cd mysql-5.6.31/
$ cmake -DCMAKE_INSTALL_PREFIX=/home/sun_zeming/mysql/mysql-3 -DMYSQL_DATADIR=/home/sun_zeming/mysql/mysql-3/data -DSYSCONFDIR=/home/sun_zeming/mysql/mysql-3/conf -DMYSQL_UNIX_ADDR=/home/sun_zeming/mysql/mysql-3/mysql.sock -DMYSQL_TCP_PORT=6660 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
$ make
$ make install

三、MySQL安装

1、进入mysql的安装路径

$ cd /home/sun_zeming/mysql/mysql-3

2、复制默认配置文件

$ cp support-files/my-default.cnf ./my.cnf

3、修改配置文件my.cnf

basedir = /home/sun_zeming/mysql/mysql-3
datadir = /home/sun_zeming/mysql/mysql-3/data
port = 6660
# server_id = .....
socket = /home/sun_zeming/mysql/mysql-3/mysql.sock

4、安装mysql

$ ./scripts/mysql_install_db --user=root --defaults-file=/home/sun_zeming/mysql/mysql-3/my.cnf

四、启动MySQL

普通用户启动

./bin/mysqld --defaults-file=/home/sun_zeming/mysql/mysql-3/my.cnf

root用户启动

./bin/mysqld --defaults-file=/home/sun_zeming/mysql/mysql-3/my.cnf --user=root

五、MySQL授权

1、设置root用户密码

$ ./bin/mysqladmin -u root password "123456"

2、登录mysql

$ ./bin/mysql -uroot -p123456 -P6660
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK