---------------------------------------------------------------
Centos7上卸载Mariadb数据库
查询所安装的MariaDB组件:
[root@localhost logs]# rpm -qa | grep Maria*
MariaDB-server-5.5.49-1.el7.centos.x86_64
MariaDB-common-5.5.49-1.el7.centos.x86_64
MariaDB-client-5.5.49-1.el7.centos.x86_64
卸载数据库:
[root@localhost logs]# yum -y remove mari*
删除数据库文件:
[root@localhost logs]# rm -rf /var/lib/mysql/*
--------------------
新的centos 7 默认已经 安装mariab
1. 先关闭 mariab:
systemctl stop mariadb
2. 安全启动
-- ps -ef | grep -i mysql
/usr/bin/mysqld_safe --skip-grant-tables >/dev/null 2>&1 &
3. 等待5秒,进入mysql
/usr/bin/mysql -u root mysql
4. 修改数据库密码
update user set password = Password('password') where User = 'root';
flush privileges;
----------
可以不用
yum install mariadb mariadb-server
systemctl start mariadb ==> 启动mariadb
systemctl enable mariadb ==> 开机自启动
mysql_secure_installation ==> 安全配置向导
mysql -u root -p root ==> 测试登录
---------------------------------------------------------------
1、下载mysql 下载地址:http://dev.mysql.com/downloads/mysql/5.6.html
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2、
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
3、 添加用户组和用户
groupadd mysql
useradd -g mysql mysql
mkdir -p /home/mysql /home/mysql/data /home/mysql/log
cp mysql-5.6.33-linux-glibc2.5-x86_64/* /home/mysql/
chown -R mysql:mysql /home/mysql/
4、创建配置my.cnf
创建my.cnf文件
vim /etc/my.cnf
复制my.cnf
复制代码
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
server_id=10
port = 3306
user = mysql
character-set-server = utf8mb4
default_storage_engine = innodb
log_timestamps = SYSTEM
socket = /tmp/mysql.sock
basedir = /home/mysql
datadir = /home/mysql/data
pid-file = /home/mysql/data/mysql.pid
max_connections = 1000
max_connect_errors = 1000
table_open_cache = 1024
max_allowed_packet = 128M
open_files_limit = 65535
innodb_buffer_pool_size = 1024M
innodb_file_per_table = 1
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_purge_threads = 2
innodb_flush_log_at_trx_commit = 1
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M
innodb_max_dirty_pages_pct = 80
innodb_lock_wait_timeout = 30
innodb_data_file_path=ibdata1:1024M:autoextend
log_error = /home/mysql/log/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /home/mysql/log/mysql-slow.log
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
5、安装 初始化mysql数据库
cd /home/mysql/
./bin/mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize
./bin/mysqld --user=mysql --basedir=/data/opt/mysql/ --datadir=/data/opt/mysql/data/ --initialize
6、 检测下是否能启动mysql服务
Starting MySQL.. SUCCESS!
启动成功以后,修改root密码
mysql -uroot -p生成的密码
登录(密码在log里面找): bin]# ./mysql -u root -p
set password=password("youpassword");
flush privileges;
mysql远程授权
grant all privileges on *.* to 'root'@'%' identified by 'youpassword';
flush privileges;
7. 配置mysql服务开机自动启动
拷贝启动文件到/etc/init.d/下并重命令为mysqld
chmod u+x /etc/init.d/mysqld
检查自启动项列表中没有mysqld这个,如果没有就添加mysqld:
设置MySQL在345等级自动启动
或用这个命令设置开机启动:
8. mysql服务的启动/重启/停止
启动mysql服务
重启mysql服务
停止mysql服务
报错如上图,需要安装libaio.so.1
64位系统安装:
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm
rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm
1
apt-get install libaio1 libaio-dev
On Redhat/Fedora/CentOS:
1
yum install libaio