1.安装
CentOS下先卸载自带的mariadb
rpm -qa | grep mariadb mariadb-libs-5.5.50-1.el7_2.x86_64 mariadb-5.5.50-1.el7_2.x86_64 mariadb-server-5.5.50-1.el7_2.x86_64 rpm -e --nodeps mariadb-libs-5.5.50-1.el7_2.x86_64
rpm -ivh mysql-community-common-5.7.12-1.el6.x86_64.rpm rpm -ivh mysql-community-libs-5.7.12-1.el6.x86_64.rpm rpm -ivh mysql-community-client-5.7.12-1.el6.x86_64.rpm rpm -ivh mysql-community-server-5.7.12-1.el6.x86_64.rpm
2.密码修改
# service mysqld stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # mysql -u root -pmysql
mysql> UPDATE user SET Password=PASSWORD('welcome1') where USER='root'; mysql> FLUSH PRIVILEGES; mysql> quit # /etc/init.d/mysql restart # mysql -uroot -p
如果出现Unknown column 'password' in 'field list'
修改语句
update mysql.user set authentication_string=password('welcome1') where user='root'
3.建表
mysql> create database mydb; Query OK, 1 row affected (0.02 sec) mysql> use mydb; Database changed mysql> create table student(stuID char(20),stuName char(20)); Query OK, 0 rows affected (0.08 sec) mysql>insert into student values('abc','jack'); Query OK, 1 row affected (0.03 sec)
4.远程连接端口,基于命令查看
show global variables like 'port';
修改/etc/my.cnf文件
[root@master ~]# cat /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M port=3306 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
5.远程连接的权限问题
tomcat端报错
数据库端错误运行授权出错
mysql> grant all privileges on *.* to 'root'@'%' with grant option; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Your password does not satisfy the current policy requirements
解决方法:
mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set host = '%' where user = 'root'; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
几经周折,调通收场。明天折腾搬上Kubernetes环境