liunx系统二进制包安装编译mysql数据库

liunx系统二进制包安装编译mysql数据库

# 解压二进制压缩包
[root@localhost ~]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/mysql-5.5.32-linux2.6-x86_64/
[root@localhost mysql-5.5.32-linux2.6-x86_64]# cd .. # 给解压后的包改一个简短的名字
[root@localhost local]# mv mysql-5.5.32-linux2.6-x86_64/ mysql
[root@localhost local]# cd mysql/ # 创建mysql用户组
[root@localhost mysql]# groupadd mysql # 创建mysql系统用户
[root@localhost mysql]# useradd mysql -g mysql -M -s /sbin/nologin # 进行账户信息授权
[root@localhost mysql]# chown -R mysql.mysql /usr/local/mysql/data/ # 开始编译mysql
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
# 出现两个OK表示成功
Installing MySQL system tables...
OK
Filling help tables...
OK
......
.......... # 复制mysql文件到开机启动项
[root@localhost mysql]# \cp support-files/mysql.server /etc/init.d/mysqld #修改配置文件
[root@localhost mysql]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql datadir=/usr/local/mysql/data
[root@localhost mysql]# cp support-files/my-small.cnf /etc/my.cnf # 启动mysql
[root@localhost mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
[root@localhost mysql]# ss -antup | grep mysql
[root@localhost mysql]# ss -antup | grep 3306
tcp LISTEN 0 50 *:3306 *:* users:(("mysqld",pid=51774,fd=10))
total 76
drwxr-xr-x 2 root root 4096 Mar 27 13:09 bin 注释:# 如果无法登录mysql进入/tmp目录修改文件权限
[root@localhost /]# cd tmp/
[root@localhost tmp]# chmod 777 mysql.sock
[root@localhost tmp]# ll
total 8
srwxrwxrwx 1 mysql mysql 0 Mar 27 13:17 mysql.sock
drwx------ 3 root root 4096 Mar 25 05:50 systemd-private-ff745f55df9148699f5cdffdd3b127e8-vgauthd.service-erHGUR
drwx------ 3 root root 4096 Mar 25 05:50 systemd-private-ff745f55df9148699f5cdffdd3b127e8-vmtoolsd.service-uPpjWH # 给mysql设置密码
[root@localhost tmp]# /usr/local/mysql/bin/mysqladmin -u root password '123456' # 设置软连接使mysql命令可以被系统找到
[root@localhost sbin]# ln -s /usr/local/mysql/bin/* /usr/local/bin/
[root@localhost sbin]# which mysql
/usr/local/bin/mysql # 登录MySQL
[root@localhost sbin]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.32 MySQL Community Server (GPL) Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec) mysql> exit
Bye
上一篇:Android性能优化之UncaughtExceptionHandler定制自己的错误日志系统


下一篇:HDU 1455 http://acm.hdu.edu.cn/showproblem.php?pid=1455