标签:mysql
1、查看系统环境
[root@c6-3 ~]# cat /etc/issue CentOS release 6.8 (Final) Kernel \r on an \m [root@c6-3 ~]# uname -a Linux c6-3.com 2.6.32-642.1.1.el6.x86_64 #1 SMP Tue May 31 21:57:07 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
2、卸载系统原有的mysql相关的包
[root@c6-3 ~]# rpm -qa | grep mysql mysql-libs-5.1.73-7.el6.x86_64 [root@c6-3 ~]# rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64
3、上传安装包到服务器,查看效果
[root@c6-3 tools]# pwd /tools [root@c6-3 tools]# ll total 29580 -rw-r--r-- 1 root root 5691656 Jun 15 12:00 cmake-2.8.8.tar.gz -rw-r--r-- 1 root root 24596474 Jun 15 12:10 mysql-5.5.32.tar.gz
4、解压、配置、编译、安装cmake,退出
[root@c6-3 tools]# tar xf cmake-2.8.8.tar.gz [root@c6-3 tools]# cd cmake-2.8.8 [root@c6-3 cmake-2.8.8]# ./configure [root@c6-3 cmake-2.8.8]# gmake [root@c6-3 cmake-2.8.8]# gmake install [root@c6-3 cmake-2.8.8]#cd ..
5、安装依赖包
[root@c6-3 tools]# yum -y install ncurses-devel
6、创建mysql用户和组
[root@c6-3 tools]# useradd -s /sbin/nologin -M mysql [root@c6-3 tools]# id mysql uid=500(mysql) gid=500(mysql) groups=500(mysql)
7、解压、配置、编译、安装mysql5.5.32
[root@c6-3 tools]# tar xf mysql-5.5.32.tar.gz [root@c6-3 tools]# cd mysql-5.5.32 [root@c6-3 mysql-5.5.32]# 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_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=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 [root@c6-3 mysql-5.5.32]# make && make install
8、创建软连接
[root@c6-3 mysql-5.5.32]# pwd /tools/mysql-5.5.32 [root@c6-3 mysql-5.5.32]# ln -s /application/mysql-5.5.32/ /application/mysql
9、选择配置文件my.cnf
[root@c6-3 mysql-5.5.32]# pwd /tools/mysql-5.5.32 [root@c6-3 mysql-5.5.32]# cd ../ [root@c6-3 tools]# cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
10、配置检查环境变量
[root@c6-3 tools]# echo "export PATH=//application/mysql/bin:$PATH" >> /etc/profile [root@c6-3 tools]# tail -1 /etc/profile export PATH=//application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin [root@c6-3 tools]# source /etc/profile [root@c6-3 tools]# echo $PATH //application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
11、授权
[root@c6-3 tools]# chown -R mysql.mysql /application/mysql/data/ [root@c6-3 tools]# chmod -R 1777 /tmp/
12、初始化数据文件
[root@c6-3 tools]# cd /application/mysql/scripts/ [root@c6-3 scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
提示OK
Installing MySQL system tables... OK Filling help tables... OK
13、把启动mysql的脚本拷贝到/etc/init.d/命名mysqld,添加可执行权限
[root@c6-3 mysql-5.5.32]# pwd /tools/mysql-5.5.32 [root@c6-3 mysql-5.5.32]# /bin/cp support-files/mysql.server /etc/init.d/mysqld [root@c6-3 mysql-5.5.32]# chmod +x /etc/init.d/mysqld
14、启动并检查端口,进程
[root@c6-3 mysql-5.5.32]# /etc/init.d/mysqld start Starting MySQL... SUCCESS! [root@c6-3 mysql-5.5.32]# ps -ef | grep mysql root 28128 1 0 22:36 pts/0 00:00:00 /bin/sh /application/mysql-5.5.32/bin/mysqld_safe --datadir=/application/mysql-5.5.32/data --pid-file=/application/mysql-5.5.32/data/c6-3.com.pid mysql 28374 28128 2 22:36 pts/0 00:00:00 /application/mysql-5.5.32/bin/mysqld --basedir=/application/mysql-5.5.32 --datadir=/application/mysql-5.5.32/data --plugin-dir=/application/mysql-5.5.32/lib/plugin --user=mysql --log-error=/application/mysql-5.5.32/data/c6-3.com.err --pid-file=/application/mysql-5.5.32/data/c6-3.com.pid --socket=/application/mysql-5.5.32/tmp/mysql.sock --port=3306 root 28397 1144 0 22:37 pts/0 00:00:00 grep mysql [root@c6-3 mysql-5.5.32]# netstat -anpt | grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 28374/mysqld
15、登陆mysql,删除空的用户登陆
[root@c6-3 mysql-5.5.32]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 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> select user,host from mysql.user; +------+-----------+ | user | host | +------+-----------+ | root | 127.0.0.1 | | root | ::1 | | | c6-3.com | | root | c6-3.com | | | localhost | | root | localhost | +------+-----------+ 6 rows in set (0.00 sec) mysql> delete from mysql.user where host=‘c6-3.com‘; Query OK, 2 rows affected (0.00 sec) mysql> delete from mysql.user where user=‘‘; Query OK, 1 row affected (0.00 sec) mysql> delete from mysql.user where host=‘::1‘; Query OK, 1 row affected (0.00 sec) mysql> select user,host from mysql.user; +------+-----------+ | user | host | +------+-----------+ | root | 127.0.0.1 | | root | localhost | +------+-----------+ 2 rows in set (0.00 sec)
16、额外添加管理员
mysql> grant all privileges on *.* to ‘system‘@‘localhost‘ identified by ‘test123‘ with grant option; Query OK, 0 rows affected (0.00 sec)
with grant option的意思是授权system用户有给其他用户授权的权限
17、退出mysql,为root添加密码,不是修改密码
[root@c6-3 ~]#/application/mysql//bin/mysqladmin -u root password ‘test123‘
标签:mysql
原文地址:http://zxygp.blog.51cto.com/8833352/1789458