MySQL编译安装
添加mysql组
添加mysql用户到mysql组
-s /bin/false用户登录不能执行命令
hurry: groupadd mysql
hurry: useradd -r -g mysql -s /bin/false mysql
hurry: wget http://downloads.mysql.com/archives/get/file/mysql-5.6.27.tar.gz
hurry: tar zxvf mysql-VERSION.tar.gz
hurry: cd mysql-5.6.27
hurry: cmake -DCMAKE_INSTALL_PREFIX=/home/hurry/software/mysql \
> -DMYSQL_DATADIR=/home/hurry/software/mysql/data \
> -DSYSCONFDIR=/etc/mysql/3306.conf \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DENABLED_LOCAL_INFILE=1 \
> -DEXTRA_CHARSETS=all \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1
hurry: make & make install
编译成功后,PREFIX生成文件。
cmake 参数说明:
- -DCMAKE_INSTALL_PREFIX=/home/hurry/software/mysql \
mysql安装目录
- -DMYSQL_DATADIR=/home/hurry/software/mysql/data \
数据保存位置
- -DSYSCONFDIR=/etc/mysql/3306.conf \
配置文件目录
- -DDEFAULT_CHARSET=utf8 \
编码格式
- -DDEFAULT_COLLATION=utf8_general_ci \
校验编码
- -DENABLED_LOCAL_INFILE=1 \
允许从本地导入数据
- -DEXTRA_CHARSETS=all \
安装所有扩展字符集
- -DWITH_MYISAM_STORAGE_ENGINE=1 \
MYISAM储存引擎
- -DWITH_INNOBASE_STORAGE_ENGINE=1
INNOB储存引擎
创建数据和日志文件夹
hurry: mkdir -p ../mysql/data/
hurry: mkdir -p ../mysql/log/
hurry: chown -R mysql:mysql ../mysql
拷贝配置文件,启动文件
hurry: cd support-files/
hurry: cp my-large.cnf /etc/my.cnf //mysql默认读取配置文件/etf/my.cnf
hurry: cp mysql.server /etc/init.d/mysqld
hurry: service mysqld start //启动mysql服务
MySQL登录
hurry: mysql -u root -p
错误处理
1.
问题:执行cmake显示一下报错信息
– Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Please install appropriate package,
处理:
hurry: sudo apt-get install libncurses5-dev
hurry: sudo apt install bison
2.
问题:
mysql启动,提示一下信息
mysql Failed to start service: Unit service not found.
查看MySQL服务
hurry@hurry:~$ service mysqld status
MySQL is not running failed
mysqld.service
Loaded: not-found (Reason: NOT found)
Active: inactive (dead)
systemd[1]: Stopped LSB: Start the MySQL database server.
处理:
hurry@hurry:~$ systemctl enable mysqld.service
3.
问题:mysql 启动失败,提示以下信息
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
执行
systemctl status mysqld.service
显示以下信息:
hurry:~$ systemctl status mysqld.service
● mysqld.service - LSB: start and stop MySQL
Loaded: loaded (/etc/init.d/mysqld; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since 四 2016-09-01 14:09:58 CST; 8s ago
Docs: man:systemd-sysv-generator(8)
Process: 2658 ExecStart=/etc/init.d/mysqld start (code=exited, status=1/FAILUR
9月 01 14:09:56 hurry systemd[1]: Starting LSB: start and stop MySQL...
9月 01 14:09:56 hurry mysqld[2658]: Starting MySQL
9月 01 14:09:58 hurry mysqld[2658]: .. * The server quit without updating PID file
9月 01 14:09:58 hurry systemd[1]: mysqld.service: Control process exited, code=e
9月 01 14:09:58 hurry systemd[1]: Failed to start LSB: start and stop MySQL.
9月 01 14:09:58 hurry systemd[1]: mysqld.service: Unit entered failed state.
9月 01 14:09:58 hurry systemd[1]: mysqld.service: Failed with result 'exit-code'
第10行信息说明不能更新.pid文件,可能是权限不足,或者my.cnf文件中.pid设置路径错误。
查看my.cnf文件发现pid-file=/var/run/mysql/3306.pid
,而路径/var/run/mysql/文件夹不存在。
处理:
创建/var/run/mysql/
sudo mkdir -p /var/run/mysql