1.MySQL简介
1.1数据库有很多类型:
关系型数据库-->MySQL Oracle
非关系型数据库-->memcached redis
1.2什么叫关系型数据库???
SQL数据库数据与数据之间是有关系的,通过关系能够将一系列数据都提取出来。
1.3什么叫非关系型数据库???
NOSQL(not only SQL)数据库
2.安装源码编译必备的几个软件包
[root@yangwenbo yang]# yum -y install make gcc gcc-c++ ncurses-devel cmake
[root@yangwenbo yang]# rpm -qa make gcc gcc-c++ ncurses-devel cmake
gcc-4.4.7-4.el6.x86_64
cmake-2.6.4-5.el6.x86_64
gcc-c++-4.4.7-4.el6.x86_64
ncurses-devel-5.7-3.20090208.el6.x86_64
make-3.81-20.el6.x86_64
3.源码编译与安装
3.1源码编译cmake-2.8.6.tar.gz
[root@yangwenbo yang]# ls cmake-2.8.6.tar.gz mysql-5.5.22.tar.gz
3.1.1解包
[root@yangwenbo yang]# tar xf cmake-2.8.6.tar.gz -C /usr/src/
3.1.2去解包后的文件存放位置的目录
[root@yangwenbo yang]# cd /usr/src/cmake-2.8.6/
3.1.3编译安装
[root@yangwenbo cmake-2.8.6]# ./configure && gmake && gmake install #以下省略。。。
- 耐心等待...
3.1.4编译成功
[root@Mysql cmake-2.8.6]# echo $? 0
3.2源码编译mysql-5.5.22.tar.gz
[root@yangwenbo yang]# ls cmake-2.8.6.tar.gz mysql-5.5.22.tar.gz
3.2.1创建程序用户
[root@yangwenbo yang]# useradd -s /sbin/nologin -M mysql [root@yangwenbo yang]# id mysql uid=500(mysql) gid=500(mysql) groups=500(mysql)
3.2.2解包
[root@yangwenbo yang]# tar xf mysql-5.5.22.tar.gz -C /usr/src/
3.2.3去解包后的文件存放位置的目录
[root@yangwenbo yang]# cd /usr/src/mysql-5.5.22/
3.2.4编译安装
[root@yangwenbo mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all && make && make install
#以下省略。。。
4.安装后优化操作
4.1修改mysql
安装目录的属主
[root@Mysql /]# chown -R mysql /usr/local/mysql/ [root@Mysql /]# ll -d /usr/local/mysql/ drwxr-xr-x. 13 mysql root 4096 Aug 19 00:19 /usr/local/mysql/
4.2创建修改my.cnf
配置文件
[root@Mysql mysql]# /bin/cp support-files/my-medium.cnf /etc/my.cnf
4.3创建修改mysqld
的启动脚本
[root@Mysql mysql]# /bin/cp support-files/mysql.server /etc/init.d/mysqld
4.4为启动脚本加上X
权限
[root@Mysql mysql]# chmod +x /etc/init.d/mysqld [root@Mysql mysql]# ll -d /etc/init.d/mysqld -rwxr-xr-x. 1 root root 10650 Aug 19 01:08 /etc/init.d/mysqld
4.5添加至系统服务(开机自启动)
[root@Mysql mysql]# chkconfig mysqld --add [root@Mysql mysql]# chkconfig mysqld --list mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
4
[root@Mysql mysql]# which mysql #一开始找不到这个命令 /usr/bin/which: no mysql in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin) [root@Mysql mysql]# ln -s /usr/local/mysql/bin/* /usr/local/bin/ [root@Mysql mysql]# which mysql #通过软连接,已经可以找到这个命令 /usr/local/bin/mysql
4.6.2使用环境变量


4.7执行mysql_install_db
脚本初始化数据库
[root@Mysql mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ #以下省略。。。
4.8启动mysql
服务,并查看运行状态
[root@Mysql mysql]# /etc/init.d/mysqld start Starting MySQL... SUCCESS! [root@Mysql mysql]# netstat -anpt | grep :3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 40589/mysqld
5.登录MySQL
5.1进入

5.2MySQL参数

5.3为MySQL
设置密码
[root@Mysql mysql]# mysqladmin -uroot password '971108'
5.4用户登录

不交互登录
[root@Mysql mysql]# mysql -uroot -p971108 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.22-log Source distribution Copyright (c) 2000, 2011, 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> #登录成功,配置完成
6.误删tmp
目录下的文件
6.1已知误删tmp
目录下的文件

6.2修改MySQL
配置文件


6.3重启MySQL

6.4查看

来源:https://www.cnblogs.com/pszx2/p/12270167.html