mysql-5.5.32编译安装

一、编译安装mysql-5.5.32及其依赖包
1、安装依赖包

yum -y install ncurses-devel cmake

二、安装mysql
2.1、创建用户和组

groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql

2.2、下载mysql

https://downloads.mysql.com/archives/get/p/23/file/mysql-5.5.32.tar.gz

三、解压编译mysql

tar xf mysql-5.5.32.tar.gz
cd mysql-5.5.32

3.1、编译mysql

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 -DMYSQL_DATADIR=/application/mysql-5.5.32/data -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_genneral_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,asscii -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_EBGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0

3.2、安装

make && make install

四、创建软连接

ln -s /application/mysql-5.5.32 /application/mysql

五、复制配置文件

cp /root/mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf

六、配置环境变量

echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
tail -1 /etc/profile
source /etc/profile
echo $PATH

七、初始化数据库

mkdir -p /application/mysql/data
chown -R mysql:mysql /application/mysql/
chmod -R 1777 /tmp

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql

八、复制启动文件

cp /root/mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start

九、登录测试

[root@mysql mysql-5.5.32]# mysql
mysql: Collation 'utf8_genneral_ci' is not a compiled collation and is not specified in the '/application/mysql-5.5.32/share/charsets/Index.xml' file
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.32 Source distribution

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> 

mysql> select user,host from mysql.user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
|      | localhost |
| root | localhost |
|      | mysql     |
| root | mysql     |
+------+-----------+
6 rows in set (0.00 sec)

mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)


mysql> select user,host from mysql.user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
| root | localhost |
| root | mysql     |
+------+-----------+
4 rows in set (0.00 sec)

十、设置新密码

/application/mysql/bin/mysqladmin -u root password 'new-password'
/application/mysql/bin/mysqladmin -u root -h mysql password 'new-password'

附加内容:授权新用户

grant all privileges on *.* to system@'localhost' identified by '123com' with grant option;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

运维那些事~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值