mysql-Linux下安装5.5版本

1)安装mysql(5.5版本)

1
2
3
4
5
6
7
8
9
tar zxvf mysql-5.5.40.tar.gz
cd mysql-5.5.4
yum install ncurses-devel cmake bison-devel libaio-devel gcc-c++ bison -y
# mysql5.5 版本之后,预编译的 configure命令改为了 cmake, 需要手动安装一下 cmake命令
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql-5.5.40

————预编译无报错,成功。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# make
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
————无报错,make正常。
# make install
-- Installing: /usr/local/mysql/man/man1/mysql_fix_extensions.1
-- Installing: /usr/local/mysql/man/man1/mysqldumpslow.1
-- Installing: /usr/local/mysql/man/man1/mysql_secure_installation.1
-- Installing: /usr/local/mysql/man/man8/mysqld.8
————无报错,make install正常。
# groupadd mysql
————创建mysql组
# useradd -g mysql mysql
————在mysql组中创建mysql用户
# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
————默认没有mysql的配置文件,将源码包中的配置文件拷贝到etc下的配置文件中。
# /usr/local/mysql/scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data
————初始化数据库,指定用户为mysql,家目录为/usr/local/mysql,数据库目录为/usr/local/mysql/data
# chown -R root /usr/local/mysql/
————改变目录的所有者
# chown -R mysql /usr/local/mysql/data
————改变目录的所有者
# chgrp -R mysql /usr/local/mysql/
————改变目录的所属组
# export PATH=$PATH:/usr/local/mysql/bin
————将/usr/local/mysql/bin下的命令放到环境变量中
# /usr/local/mysql/bin/mysqld_safe –user=mysql &

————启动mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1

Mysql启动、停止的方法
# /usr/local/mysql/bin/mysqld_safe –user=mysql & 启动
# mysqladmin –uroot –pxxx shutdown 停止
# tail -f /var/log/mysqld.log 查看mysql的错误日志

修改 mysql监听地址为127.0.0.1
# netstat -ntulp
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 28253/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1889/sshd

默认是监听的0.0.0.0
# vi /etc/my.cnf
添加一列
[mysqld]
port = 3306
socket = /tmp/mysql.socK
bind-address=127.0.0.1
# mysqladmin -uroot -p shutdow
# /usr/local/mysql/bin/mysqld_safe –user=mysql &
# netstat -ntulp
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 29103/mysqld

————修改成功

修改 mysql的root密码

1
2
3
4
5
6
use mysql
update user set Password=PASSWORD(‘新密码’) where User=’root’ and Host=’localhost’;
flush privileges;flush privileges;
# mysql -uroot -p
Enter password:
mysql>

————修改新密码成功

  • 版权声明: 本博客所有文章,未经许可,任何单位及个人不得做营利性使用!转载请标明出处!如有侵权请联系作者。
  • Copyrights © 2015-2020 翟天野

请我喝杯咖啡吧~