分类: LINUX
2018-08-08 08:50:09
mysql数据库非常重要。注意安装过程。
[root@localhost bison-2.5]# yum -y install gcc*
[root@localhost soft]# tar -zxf bison-2.5.tar.gz -C /usr/src/
[root@localhost soft]# tar -zxf cmake-2.8.7.tar.gz -C /usr/src/
[root@localhost soft]# tar -zxf mysql-5.5.22.tar.gz -C /usr/src/
[root@localhost soft]# cd /usr/src/bison-2.5/
[root@localhost bison-2.5]# ./configure && make && make install
[root@localhost bison-2.5]# cd /usr/src/cmake-2.8.7/
[root@localhost cmake-2.8.7]# ./bootstrap && gmake && gmake install
[root@localhost mysql-5.5.22]# yum -y install ncurses-devel
如果在安装MySQL之前忘记安装这个程序,则需要执行
[root@localhost mysql-5.5.22]# rm -rf CMakeCache.txt
然后再重新配置(cmake)
[root@localhost cmake-2.8.7]# cd /usr/src/mysql-5.5.22/
[root@localhost mysql-5.5.22]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DSYSCONFDIR=/etc \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DWITH_EXTRA_CHATSETS=all
[root@localhost mysql-5.5.22]# useradd -M -s /sbin/nologin mysql
[root@localhost mysql-5.5.22]# chown -R mysql.mysql /usr/local/mysql
[root@localhost mysql-5.5.22]# mkdir -p /var/mysql/{data,log}
[root@localhost mysql-5.5.22]# chown -R mysql.mysql /var/mysql/
[root@localhost mysql-5.5.22]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
[root@localhost support-files]# pwd
/usr/src/mysql-5.5.22/support-files
[root@localhost support-files]# cp my-large.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db \
> --defaults-file=/etc/my.cnf \
> --basedir=/usr/local/mysql/ \
> --datadir=/var/mysql/data/ \
> --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
确认初始化成功
将 mysql 加入开机启动
# chmod +x /etc/init.d/mysqld
# vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内
容:)
basedir=/usr/local/mysql
datadir=/var/mysql/data
[root@localhost ~]# chkconfig --add mysqld
[root@localhost ~]# chkconfig --level 345 mysqld on
[root@localhost ~]# service mysqld start
Starting MySQL... [确定]
尝试登陆:报错,环境变量
[root@localhost ~]# mysql -uroot -p
bash: mysql: command not found
~]# echo "PATH=$PATH:/usr/local/mysql/bin" > /etc/profile
[root@localhost ~]# . /etc/profile
[root@localhost ~]# mysql -uroot -p
Enter password: 【初次登陆为空密码】
......
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
登陆成功
扩展
mysql5.5源码编译安装
mysql5.7二进制包安装(变化较大)