$ /mysql/scripts/mysql_install_db --datadir=/mysql/data --basedir=/mysql

support-files/mysql.server脚本启动mysql不推荐,推荐使用mysqld_safe启动:

$ mysqld_safe --defaults-file=/mysql/conf/my.cnf &

netstat -lnt |grep 3306

ps -ef |grep mysql 查看mysql端口和进程

配置mysql

mysql5.6默认root用户不设密码的直接敲入mysql登录。

增强安全性:

select user,host from mysql.user;

+------+-----------+

| user | host |

+------+-----------+

| root | 127.0.0.1 |

| root | ::1 |

| | linux01 |

| root | linux01 |

| | localhost |

| root | localhost |

+------+-----------+

6 rows in set (0.01 sec)

6个用户,两个用户没有用户名。所以直接可通过mysql登录。

下面保留一条root用户其他用户全部删除。

修改root用户名

update mysql.user set user=‘system‘,password=password(‘oralinux‘);

(root@localhost) [(none)]>select * from mysql.db \G

truncate table mysql.db;

root@localhost) [(none)]>exit

Bye

[mysql@linux01 mysql]$ mysql

ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

[mysql@linux01 mysql]$ mysql -uroot -p‘oralinux‘

Warning: Using a password on the command line interface can be insecure.

ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)

[mysql@linux01 mysql]$ mysql -usystem -p‘oralinux‘

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.6.34-log JASON

Copyright (c) 2000, 2016, 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.

(system@localhost) [(none)]>

创建管理脚本,创建中间定义文件,目的是提高脚本的复用性:

vi /mysql/scripts/mysql_env.ini

#set env

MYSQL_USER=system

MYSQL_PASS=‘oralinux‘

#check parameter

if [ $# -ne 1 ]

then

HOST_PORT=3306

else

HOST_PORT=$1

fi

$ chmod 600 /mysql/scripts/mysql_env.ini

创建mysql_db_startup.sh脚本,用于启动mysql服务:

#!/bin/sh

# Created by jason

source /mysql/scripts/mysql_env.ini

echo "Startup MySQL Service:localhost_"${HOST_PORT}

/mysql/bin/mysqld_safe --defaults-file=/mysql/conf/my.cnf &

$ vi /mysql/scripts/mysql_db_shutdown.sh

#!/bin/sh

#Created by jason

source /mysql/scripts/mysql_env.ini

echo "Shutdown MySQL Service:localhost_"${HOST_PORT}

/mysql/bin/mysqladmin -u${MYSQL_USER} -p${MYSQL_PASS} -S /mysql/conf/mysql.sock shutdown

创建sqlplus.sh脚本用于快速登录:

$vi /mysql/scripts/sqlplus.sh

#!/bin/sh

#Created by jason

source /mysql/scripts/mysql_env.ini

echo "Login MySQL Service:localhost_"${HOST_PORT}

/mysql/bin/mysql -u${MYSQL_USER} -p${MYSQL_PASS} -S /mysql/conf/mysql.sock $2

chmod +x /mysql/scripts/sqlplus.sh

编辑mysql用户变量,将上述路径加入到PATH中

echo "export PATH=/mysql/scripts:\$PATH" >> ~/.bash_profile

source ~/.bash_profile

设置开机启动:root下

# vi /etc/rc.localhost

# autostart mysql ,added by jason at 2017-03-31

sudo -i -u mysql /mysql/scripts/mysql_db_startup.sh 3306 > /mysql/logs/mysql_db_startup.log 2>&1

执行sudo命令遇到下列错误:

sudo:sorry,you must have a tty to run sudo

vi /etc/sudoers 注释掉56行

#Defaultsrequiretty

涂抹mysql笔记-管理mysql服务

标签:efault   group   变量   max   profile   通过   chmod   mysqld   ase

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:http://www.cnblogs.com/datalife/p/6688328.html

涂抹mysql 完整_涂抹mysql笔记-管理mysql服务相关推荐

  1. linux mysql怎么样_最强Linux和Mysql面试题套餐,让你的面试无懈可击!

    引言: 大家好,我是一菲,在软件测试当中linux 操作系统和Mysql数据库的内容是十分的知识同时也是十分重要的.所以一菲这两天通过查阅资料等其他方式为大家梳理了liunx和Mysql面试题大礼包, ...

  2. mysql终端_MySQL之终端(Terminal)管理MySQL

    前言:MySQL有很多的可视化管理工具,比如"mysql-workbench"和"sequel-pro-". 现在我写MySQL的终端命令操作的文章,是想强化一 ...

  3. 认识mysql总结_从根上理解Mysql - 读后个人总结1-搜云库

    初识 MySQL 通信介绍 MySQL 也是典型的 C / S 模型,分为客户端及服务端,服务端一般部署在远端服务器中,也可以部署至本地,然后客户端跟服务端通信则可以使用依赖网络的 TCP 长连接或 ...

  4. 如何用c 控制mysql数据库_用C语言操作MySQL数据库

    函数 描述 mysql_affected_rows() 返回上次UPDATE.DELETE或INSERT查询更改/删除/插入的行数. mysql_autocommit() 切换autocommit模式 ...

  5. linux mysql可视化_常用的 7 款 MySQL 客户端工具,你值得拥有!

    MySQL的管理维护工具非常多,除了系统自带的命令行管理工具之外,还有许多其他的图形化管理工具,这里我介绍几个经常使用的MySQL图形化管理工具,供大家参考. 1.phpMyAdmin http:// ...

  6. apch连接mysql数据库连接_配置phpmyadmin连接远程 MySQL数据库

    Mysql 服务器上面安装mysql yum -y install mysql mysql-devel mysql-server mysql-* 首次安装后,执行 #mysql 后,执行修改密码操作 ...

  7. jsp和mysql答辩_如何应对JSP连接MySQL数据库问题_网站数据库怎么连接到网页答辩问题...

    当您面临JSP连接MySQL数据库问题,你首先需要在MySQL数据库里创建一username表,表里面创建两个字符型的字段,字段名分别为:uid,pwd,然后插入几条测试数据. 以下用两种方式来实现J ...

  8. 怎么在Vc中打开MySQL数据库_在vc++中使用mysql数据库_MySQL

    vc++版本:v6.0 Host Info: localhost via TCP/IP Server Info: 5.0.67-community-nt Server Version: 50067 C ...

  9. 传智播客mysql视频_传智播客mysql高清视频教程(41集)

    本套课程为传智播客mysql高清视频教程,全套课程有41讲,是mysql入门的优质教材,随着mysql不断发展,现在使用mysql+php做网站已成为主流,如果你想学习动态网页设计,那么建议你选择ph ...

最新文章

  1. 【用深度学习搜索相似服饰】《Using Deep Learning to Find Similar Dresses》by Luis Mey
  2. ASP.NET 开发知识小结
  3. BZOJ 2287 【POJ Challenge】消失之物
  4. glibc-2.23学习笔记(二)—— free部分源码分析
  5. 太好了,一分钟带你分清Python的模块、库、包有什么联系和区别?
  6. spring 配置文件模板
  7. PHP在金山游戏运营中的应用
  8. SpringCloud Hoxton版微服务- Ribbon实现负载均衡
  9. c++头文件被c语言调用需要注意什么_嵌入式C语言之模块化编程
  10. MySQL建表(那些字段必须)命令详解
  11. 老板平常多说点好听的
  12. android appium 原理,天天使用Appium,但是你真的理解Appium的工作原理吗
  13. html判断文本框和按钮,css样式之区分input是按钮还是文本框的方法
  14. P3966 [TJOI2013]单词(AC自动机)
  15. 干货分搞私投以技术面试
  16. dede标签详细的dede标签大全,dede标签在线学习
  17. linux ps-e和-ax区别,Linux编程 6 (查看进程 ps 及输出风格)
  18. python注册登陆程序_python的简单的登陆和注册功能实现
  19. 红米2电信 android go,超能玩手机:如何让红米2电信版正确支持“全网通”?
  20. 什么是冷备份和热备份

热门文章

  1. python可以做什么系统-python什么系统
  2. cmd查看python安装路径-从cmd如何查找python的安装路径?
  3. python下什么-python官网下的包是干什么用的?
  4. python2好还是python3好-新手入门选择Python2还是Python3
  5. python使用方法视频-Python读取视频的两种方法(imageio和cv2)
  6. python电脑下载网址-python下载文件文件到本地电脑(基于requests)
  7. python语言入门pdf-python语言入门
  8. python语法基础知识-python基础必学的语法知识
  9. 怎么把python结果全部显示-python 显示数组全部元素的方法
  10. python自动化测试视频百度云-python接口自动化测试视频教程全集