环境背景:CentOS 7.2

 

 

一、编辑/usr/lib/systemd/system/mariadb.service 文件,在Service段中添加
1
2
3
4
5
6
7
8
9
10
11
12
[Service]
Type=simple
User=mysql
Group=mysql
User=mysql
Group=mysql
 
ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# per bug #547485
#在Server段中的ExecStart出添加如下
ExecStart=/usr/bin/mysqld_safe --basedir=/usr --skip-grant-tables --skip-networking

二、键入systemctl daemon-reload使其立即生效

1
[root@node1 ~]# systemctl daemon-reload
三、重新启动mariadb服务并使用mysql联入
1
2
3
4
5
6
7
8
9
10
11
[root@node1 ~]# systemctl restart mariadb.service
[root@node1 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.44-MariaDB MariaDB Server
 
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]>
四、更改root用户的密码
1
2
3
4
5
6
MariaDB [(none)]> UPDATE mysql.user SET Password=PASSWORD('xiaoshui') WHERE user='root' and host='localhost';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0
 
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
五、退出并关闭mariadb服务并把/usr/lib/systemd/system/mariadb.service文件中刚刚添加的那两行移除
1
2
ExecStart=/usr/bin/mysqld_safe --basedir=/usr 
ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID
六、启动mariadb服务,并使用新设置的密码连接
1
2
3
4
5
6
7
8
9
10
11
[root@node1 ~]# mysql -u root -h localhost -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.44-MariaDB MariaDB Server
 
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]>

参考:http://dashui.blog.51cto.com/11254923/1877042

最新文章

  1. java之内部类与匿名内部类
  2. HTML5的渐变色 渐变的两种类型 createLinearGradient 和createRadialGradient
  3. 关于数据库中varchar/nvarchar类型数据的获取注意事项
  4. (转)iOS7界面设计规范(10) - UI基础 - 文字排版与配色
  5. Android官方技术文档翻译——Ant 任务
  6. [置顶] WebService调用工具(AXIS2)
  7. Codeforces Jzzhu and Sequences(圆形截面)
  8. Extension+NVelocity
  9. js 字符串切割
  10. 金融量化分析【day112】:量化交易策略基本框架
  11. 用vue怎么写点击保存之后的返回的代码?
  12. HD,3G视频数据中行号的插入方法---Verilog代码实现
  13. sql中的begin catch 。。。end catch 的用法
  14. 微服务SpringCloud无法进行服务消费
  15. [每天解决一问题系列 - 0013] 如何修改WiX Burn内置的窗口
  16. 网页中动态嵌入PDF文件/在线预览PDF内容https://www.cnblogs.com/xgyy/p/6119459.html
  17. hdu 4941 map的使用
  18. 基于matplotlib的数据可视化(图形填充fill fill_between) - 笔记(二)
  19. handlebars——另外一个模板引擎
  20. Linux下onvif客户端获取ipc摄像头 GetStreamUri:rtsp地址(h264、h265)

热门文章

  1. VMware内CentOS7虚拟机硬盘扩容
  2. 使用nvm进行node多版本管理
  3. Android Studio下加入百度地图的使用(二)——定位服务
  4. HOW TO REPLACE ALL OCCURRENCES OF A CHARACTER IN A STD::STRING
  5. Atitit 常用sdk 模块 组织架构切分 规范与范例attilax总结
  6. Intent的作用和表现形式简单介绍
  7. 实现A星算法
  8. 登录tomcat服务器首页直接跳转到项目
  9. 【emWin】例程十一:GIF图像显示
  10. SQL 逗号分隔将一行拆成多行