标签:
MySQL学习笔记(平台CentOS 6)
1、建立mysql账号
[root@mysql-master tools]# groupadd mysql [root@mysql-master tools]# useradd -s /sbin/nologin -g mysql -M mysql
2、配置安装环境
[root@mysql-master ~]# yum groupinstall ‘Development Tools‘ -y [root@mysql-master ~]# yum install gcc gcc-c++ make ncurses-devel bison perl -y # 依赖包
安装cmake
[root@mysql-master tools]# tar -zxf cmake-2.8.12.tar.gz # 安装cmake [root@mysql-master tools]# cd cmake-2.8.12 [root@mysql-master cmake-2.8.12]# ./configure [root@mysql-master cmake-2.8.12]# gmake [root@mysql-master cmake-2.8.12]# gmake install [root@mysql-master cmake-2.8.12]# which cmake # 配置cmake环境变量 /usr/local/bin/cmake [root@mysql-master cmake-2.8.12]# echo ‘export PATH=/usr/local/bin:$PATH‘ >> /etc/profile [root@mysql-master cmake-2.8.12]# source /etc/profile
此处cmake,也可以通过“yum install cmake -y”安装,但是这种方式安装的“cmake”,在编译mysql时会有警告:
CMake Warning (dev) in sql/CMakeLists.txt: Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link interface. Run "cmake --help-policy CMP0022" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Target "mysqld" has an INTERFACE_LINK_LIBRARIES property which differs from its LINK_INTERFACE_LIBRARIES properties. INTERFACE_LINK_LIBRARIES: -lpthread;sql;mysys LINK_INTERFACE_LIBRARIES: rt This warning is for project developers. Use -Wno-dev to suppress it. -- Generating done -- Build files have been written to: /root/tools/mysql-5.5.37
3、创建安装目录
[root@mysql-master ~]# mkdir -p /usr/local/mysql # 安装目录 [root@mysql-master ~]# mkdir /db/mysql -p # 数据存储目录 [root@mysql-master ~]# chown -R mysql.mysql /usr/local/mysql [root@mysql-master ~]# chown -R mysql.mysql /db
4、安装mysql
[root@mysql-master tools]# tar -zxf mysql-5.5.37.tar.gz [root@mysql-master tools]# cd mysql-5.5.37 [root@mysql-master mysql-5.5.37]# cmake > -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \ # mysql安装路径 > -DMYSQL_DATADIR=/db/mysql/ \ # mysql数据存储路径 > -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ # 指定sock位置 > -DMYSQL_TCP_PORT=3306 \ # 指定端口 > -DEXTRA_CHARSETS=all \ # 安装所有字符集 > -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@mysql-master mysql-5.5.37]# make && make install
copy mysql配置文件,产生数据文件
[root@mysql-master mysql-5.5.37]# ll support-files/*.cnf -rw-r--r-- 1 root root 4667 Aug 18 07:30 support-files/my-huge.cnf -rw-r--r-- 1 root root 19759 Aug 18 07:30 support-files/my-innodb-heavy-4G.cnf -rw-r--r-- 1 root root 4641 Aug 18 07:30 support-files/my-large.cnf -rw-r--r-- 1 root root 4652 Aug 18 07:30 support-files/my-medium.cnf -rw-r--r-- 1 root root 2816 Aug 18 07:30 support-files/my-small.cnf [root@mysql-master mysql-5.5.37]# /bin/cp support-files/my-small.cnf /etc/my.cnf
[root@mysql-master ~]# chown -R mysql.mysql /usr/local/mysql [root@mysql-master ~]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/db/mysql --user=mysql
5、启动mysql
[root@mysql-master ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql & [root@mysql-master ~]# netstat -ntulp | grep mysqld tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 38437/mysqld
6、安装后配置
[root@mysql-master ~]# echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ >>/etc/profile [root@mysql-master ~]# source /etc/profile [root@mysql-master mysql-5.5.37]# cp support-files/mysql.server /etc/init.d/mysqld [root@mysql-master ~]# chmod 700 /etc/init.d/mysqld [root@mysql-master ~]# /etc/init.d/mysqld stop [root@mysql-master ~]# chkconfig --add mysqld [root@mysql-master ~]# chkconfig mysqld on
7、mysql配置密码
[root@mysql-master ~]# /etc/init.d/mysqld start [root@mysql-master ~]# mysqladmin -uroot password ‘q.1234‘
MySQL学习笔记(基础部分)-单实例mysql-5.5.X安装
标签:
原文地址:http://my.oschina.net/u/2428313/blog/494028