MySQL学习笔记(平台CentOS 6)
1、建立mysql账号
[[email protected] tools]# groupadd mysql [[email protected] tools]# useradd -s /sbin/nologin -g mysql -M mysql
2、配置安装环境
[[email protected] ~]# yum groupinstall ‘Development Tools‘ -y [[email protected] ~]# yum install gcc gcc-c++ make ncurses-devel bison perl -y # 依赖包
安装cmake
[[email protected] tools]# tar -zxf cmake-2.8.12.tar.gz # 安装cmake [[email protected] tools]# cd cmake-2.8.12 [[email protected] cmake-2.8.12]# ./configure [[email protected] cmake-2.8.12]# gmake [[email protected] cmake-2.8.12]# gmake install [[email protected] cmake-2.8.12]# which cmake # 配置cmake环境变量 /usr/local/bin/cmake [[email protected] cmake-2.8.12]# echo ‘export PATH=/usr/local/bin:$PATH‘ >> /etc/profile [[email protected] 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、创建安装目录
[[email protected] ~]# mkdir -p /usr/local/mysql # 安装目录 [[email protected] ~]# mkdir /db/mysql -p # 数据存储目录 [[email protected] ~]# chown -R mysql.mysql /usr/local/mysql [[email protected] ~]# chown -R mysql.mysql /db
4、安装mysql
[[email protected] tools]# tar -zxf mysql-5.5.37.tar.gz [[email protected] tools]# cd mysql-5.5.37 [[email protected] 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 [[email protected] mysql-5.5.37]# make && make install
copy mysql配置文件,产生数据文件
[[email protected] 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 [[email protected] mysql-5.5.37]# /bin/cp support-files/my-small.cnf /etc/my.cnf
[[email protected] ~]# chown -R mysql.mysql /usr/local/mysql [[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/db/mysql --user=mysql
5、启动mysql
[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql & [[email protected] ~]# netstat -ntulp | grep mysqld tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 38437/mysqld
6、安装后配置
[[email protected] ~]# echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ >>/etc/profile [[email protected] ~]# source /etc/profile [[email protected] mysql-5.5.37]# cp support-files/mysql.server /etc/init.d/mysqld [[email protected] ~]# chmod 700 /etc/init.d/mysqld [[email protected] ~]# /etc/init.d/mysqld stop [[email protected] ~]# chkconfig --add mysqld [[email protected] ~]# chkconfig mysqld on
7、mysql配置密码
[[email protected] ~]# /etc/init.d/mysqld start [[email protected] ~]# mysqladmin -uroot password ‘q.1234‘
时间: 2024-10-01 08:06:43