MYSQL简单安装配置
有用的URL:
http://www.cnblogs.com/zeroone/articles/2298942.html
http://blog.csdn.net/h1017597898/article/details/9815987
安装之后,新建用户及密码,新建数据库,分配权限
mysql> CREATE USER 'user'@'%' IDENTIFIED BY 'password'; Query OK, rows affected (0.00 sec) mysql> create database DB; Query OK, row affected (0.00 sec) mysql>create database DB default character set utf8 collate utf8_general_ci; (为了DJANGO操作中文不乱码)
Query OK, 1 row affected (0.00 sec)
rows affected ( rows affected (0.00 sec)
YUM安装的MYSQL之后,第一次启动时的安全配置:
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h cnsz141539 password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script!
如果要将MYSQL放入SERVICE服务,相应的脚本为:
#!/bin/sh # # mysqld This shell script takes care of starting and stopping # the MySQL subsystem (mysqld). # # chkconfig: - # description: MySQL database server. # processname: mysqld # config: /etc/my.cnf # pidfile: /var/run/mysqld/mysqld.pid ### BEGIN INIT INFO # Provides: mysqld # Required-Start: $local_fs $remote_fs $network $named $syslog $time # Required-Stop: $local_fs $remote_fs $network $named $syslog $time # Short-Description: start and stop MySQL server # Description: MySQL database server ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network exec="/usr/bin/mysqld_safe" prog="mysqld" # Set timeouts here so they can be overridden from /etc/sysconfig/mysqld STARTTIMEOUT= STOPTIMEOUT= [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog lockfile=/var/lock/subsys/$prog # extract value of a MySQL option from config files # Usage: get_mysql_option SECTION VARNAME DEFAULT # result is returned in $result # We use my_print_defaults which prints all options from multiple files, # with the more specific ones later; hence take the last match. get_mysql_option(){ result=`/usr/bin/my_print_defaults ` if [ -z "$result" ]; then # not found, use default result="$3" fi } get_mysql_option mysqld datadir "/var/lib/mysql" datadir="$result" get_mysql_option mysqld socket "$datadir/mysql.sock" socketfile="$result" get_mysql_option mysqld_safe log-error "/var/log/mysqld.log" errlogfile="$result" get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid" mypidfile="$result" start(){ [ -x $exec ] || exit # check to see if it's already running MYSQLDRUNNING= if [ -f "$mypidfile" ]; then MYSQLPID=`>/dev/null` if [ -n "$MYSQLPID" ] && [ -d "/proc/$MYSQLPID" ] ; then MYSQLDRUNNING= fi fi RESPONSE=`/usr/bin/mysqladmin --socket=>&` ] && [ $? = ]; then # already running, do nothing action $"Starting $prog: " /bin/true ret= ] && echo "$RESPONSE" | grep -q "Access denied for user" then # already running, do nothing action $"Starting $prog: " /bin/true ret= else # prepare for start >/dev/null ]; then # failed to touch log file, probably insufficient permissions action $"Starting $prog: " /bin/false return fi chown mysql:mysql "$errlogfile" "$errlogfile" [ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile" if [ ! -d "$datadir/mysql" ] ; then # First, make sure $datadir is there with correct permissions if [ ! -e "$datadir" -a ! -h "$datadir" ] then fi chown mysql:mysql "$datadir" "$datadir" [ -x /sbin/restorecon ] && /sbin/restorecon "$datadir" # Now create the database action $"Initializing MySQL database: " /usr/bin/mysql_install_db --datadir="$datadir" --user=mysql ret=$? chown -R mysql:mysql "$datadir" ] ; then return $ret fi fi chown mysql:mysql "$datadir" "$datadir" # We check if there is already a process using the socket file, # since otherwise this init script could report false positive # result and mysqld_safe would remove the socket file, which # actually uses a different daemon. if fuser "$socketfile" &>/dev/null ; then echo "Socket file $socketfile exists. Is another MySQL daemon already running with the same unix socket?" action $"Starting $prog: " /bin/false return fi # Pass all the options determined above, to ensure consistent behavior. # In many cases mysqld_safe would arrive at the same conclusions anyway # but we need to be sure. (An exception is that we don't force the # log-error setting, since this script doesn't really depend on that, # and some users might prefer to configure logging to syslog.) # Note: set --basedir to prevent probes that might trigger SELinux # alarms, per bug # $exec --datadir="$datadir" --socket="$socketfile" \ --pid-file="$mypidfile" \ --basedir=/usr --user=mysql >/dev/>& & safe_pid=$! # Spin for a maximum of N seconds waiting for the server to come up; # exit the loop immediately if mysqld_safe process disappears. # Rather than assuming we know a valid username, accept an "access # denied" response as meaning the server is functioning. ret= TIMEOUT="$STARTTIMEOUT" ]; do RESPONSE=`/usr/bin/mysqladmin --socket=>&` mret=$? ]; then break fi # exit codes , (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected, # anything else suggests a configuration error -a $mret -ne ]; then echo "$RESPONSE" echo "Cannot check for MySQL Daemon startup because of mysqladmin failure." ret= break fi echo "$RESPONSE" | grep -q "Access denied for user" && break $safe_pid >/dev/null; then echo "MySQL Daemon failed to start." ret= break fi let TIMEOUT=${TIMEOUT}- done ]; then echo "Timeout error occurred trying to start MySQL Daemon." ret= fi ]; then action $"Starting $prog: " /bin/true >& touch $lockfile else action $"Starting $prog: " /bin/false fi fi return $ret } stop(){ if [ ! -f "$mypidfile" ]; then # not running; per LSB standards this is "ok" action $"Stopping $prog: " /bin/true return fi MYSQLPID=`>/dev/null` if [ -n "$MYSQLPID" ]; then /bin/>& ret=$? ]; then TIMEOUT="$STOPTIMEOUT" ]; do /bin/ >& || break let TIMEOUT=${TIMEOUT}- done ]; then echo "Timeout error occurred trying to stop MySQL Daemon." ret= action $"Stopping $prog: " /bin/false else rm -f $lockfile rm -f "$socketfile" action $"Stopping $prog: " /bin/true fi else action $"Stopping $prog: " /bin/false fi else # failed to read pidfile, probably insufficient permissions action $"Stopping $prog: " /bin/false ret= fi return $ret } restart(){ stop start } condrestart(){ [ -e $lockfile ] && restart || : } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status -p "$mypidfile" $prog ;; restart) restart ;; condrestart|try-restart) condrestart ;; reload) exit ;; force-reload) restart ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit esac exit $?
MYSQL简单安装配置的更多相关文章
- tftp服务器简单安装配置
tftp服务器最简单安装配置 1.安装tftp-server sudo apt-get install tftpd-hpa sudo apt-get install tftp-hpa(如果不需要客户端 ...
- [mysql]brew 安装 配置 操作 mysql(中文问题)
mac 下卸载mysqldmg mac下mysql的DMG格式安装内有安装文件,却没有卸载文件--很郁闷的事. 网上搜了一下,发现给的方法原来得手动去删. 很多文章记述要删的文件不完整,后来在stac ...
- 阿里云服务器 ECS 部署lamp:centos+apache+mysql+php安装配置方法 (centos7)
阿里云服务器 ECS 部署lamp:centos+apache+mysql+php安装配置方法 (centos7) 1.效果图 1 2. 部署步骤 1 1. mysql安装附加(centos7) 7 ...
- java:安装tomcat8/tomcat9(简单安装配置)
java:安装tomcat8/tomcat9(简单安装配置) pache-tomcat-8.5.23(免安装板) 1.安装完成后右击我的电脑—属性—高级系统设置—环境变量, 在系统变量中添加以下变量 ...
- Mysql主从安装配置
Mysql主从安装配置 环境: 主从服务器上的MySQL数据库版本同为5.1.34 主机IP:192.168.0.1 从机IP:192.168.0.2 一. MySQL主服务器配置 1.编辑配置 ...
- mysql主从复制安装配置
mysql主从复制安装配置 基础设置准备 #操作系统: centos6.5 #mysql版本: 5.7 #两台虚拟机: node1:192.168.182.111(主) node2:192.168.1 ...
- 记一次 mysql主从复制安装配置 过程
mysql主从复制安装配置 1.centos安装及准备 去centos官网下载相应source版本的镜像文件并在vmware中安装,安装中会遇到填写installation source,输入以下即可 ...
- 虚拟机+apache+php+mysql 环境安装配置
虚拟机的安装:直接下一步即可,注意修改路径. 安装完成后新建虚拟机,直接下一步.如果选择镜像文件后出现错误,可以试着去修改电脑bios中的虚拟化设置,改为enable,如下图: apache安装: 1 ...
- Linux(Ubuntu) Mysql的安装配置例子以及常用命令
1.安装配置例子 有空再写 2.注意事项 (1)启动mysql 在/etc/mysql 目录下 service mysql start 新版本是(service mysqld start ) (2 ...
随机推荐
- LabVIEW设计模式系列——移位寄存器
标准:1.太多移位寄存器会导致连线太多,看起来凌乱,使用簇将变量打包,统一用一个移位寄存器,这样可以减少连线的麻烦2.如果每个变量都使用一个移位寄存器,没有一个名字是很难区分移位寄存器到底属于哪一个变 ...
- AS3性能及Flex-Formatting设置问题
1.支持Vector 2.for each in更是从Flash Player 9 3.Flash原生的bitmap.encode 4.如打开位图缓存:使用bitmapData.lock:把bitma ...
- iOS常见的几种延时执行的方法
1.performSelector [self performSelector:@selector(delayMethod) withObject:nil/*可传任意类型参数*/ afterDelay ...
- linux sed使用
原文引用:http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html [root@www ~]# sed [-nefr] [动作] ...
- CentOS 6.7编译安装PHP7
1.首先配置好编译环境 yum update && yum upgrade yum groupinstall "Development Tools" yum ins ...
- Bash判断是否是root
#!/bin/bash ]; then echo "Not Root" exit fi
- mac下通过docker搭建LEMP环境
在mac下通过docker搭建LEMP环境境 1.安装virtualbox.由于docker是在lxc环境的容器 2.安装boot2docker,用于与docker客户端通讯 > brew up ...
- Eclipse优化集合,Eclipse优化速度,解决Ctrl+C、Ctrl+V卡
Eclipse优化集合,Eclipse优化速度,解决Ctrl+C.Ctrl+V卡 >>>>>>>>>>>>>>> ...
- 第一篇:杂项之pymysql连接池
杂项之pymysql连接池 杂项之pymysql连接池 本节内容 本文的诞生 连接池及单例模式 多线程提升 协程提升 后记 1.本文的诞生 由于前几天接触了pymysql,在测试数据过程中,使用普 ...
- 用bootstrap的tab插件做一个图层切换效果(感觉会误导淫们,大家当乐子看吧)
小伙伴们啊,我JS真的是个渣渣,所以总想要偷懒,于是为了实现效果就把tab插件给改了(各位大神轻拍啊,我是小白,很纯洁滴,小心脏也很脆弱)…… 最近做的项目为了考虑以后的移动设备兼容性,所以用了Boo ...