1, 安装事先准备:
1-1, cmake软件
cd /home/oldboy/tools
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure
gmake
gmake install
cd ../
1-2, 依赖包
yum install ncurses-devel -y
1-3, 开始安装mysql
创建用户和组
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
1-4, 开始安装mysql
tar xf mysql-5.5.32.tar.gz
cd 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
make
make install
ln -s /application/mysql-5.5.32/ /application/mysql
1-5, 初始化配置mysql,选择配置文件模板
cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
1-6,配置环境变量
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
tail -1 /etc/profile
source /etc/profile
echo $PATH
1-7, 建立mysql数据文件目录
mkdir -p /application/mysql/data
授权mysql用户访问mysql的安装目录
chown -R mysql.mysql /application/mysql
调整/tmp权限,否则初始化会错误
chmod -R 1777 /tmp
1-8, 初始化
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
1-9,
cp /home/oldboy/tools/mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
1-10, /etc/init.d/mysqld start
到此安装完成!!
操作mysql:
mysql 的授权表
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | moban |
| root | moban |
+------+-----------+
6 rows in set (0.00 sec)
为mysql增加密码,不是改密码
/application/mysql//bin/mysqladmin -u root password 'new-password'
1-11
grant all on dbname.* 'jeffrey'@'localhost' identified by 'mypasswd';
刷新权限生效:
flush privileges;
创建新用户并指定密码:
mysql> create user oldboygirl@localhost identified by 'oldboy123';
Query OK, 0 rows affected (0.00 sec)
再去root用户登陆mysql,为新用户授权。