有用的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简单安装配置的更多相关文章

  1. tftp服务器简单安装配置

    tftp服务器最简单安装配置 1.安装tftp-server sudo apt-get install tftpd-hpa sudo apt-get install tftp-hpa(如果不需要客户端 ...

  2. [mysql]brew 安装 配置 操作 mysql(中文问题)

    mac 下卸载mysqldmg mac下mysql的DMG格式安装内有安装文件,却没有卸载文件--很郁闷的事. 网上搜了一下,发现给的方法原来得手动去删. 很多文章记述要删的文件不完整,后来在stac ...

  3. 阿里云服务器 ECS 部署lamp:centos+apache+mysql+php安装配置方法 (centos7)

    阿里云服务器 ECS 部署lamp:centos+apache+mysql+php安装配置方法 (centos7) 1.效果图 1 2. 部署步骤 1 1. mysql安装附加(centos7) 7 ...

  4. java:安装tomcat8/tomcat9(简单安装配置)

    java:安装tomcat8/tomcat9(简单安装配置) pache-tomcat-8.5.23(免安装板) 1.安装完成后右击我的电脑—属性—高级系统设置—环境变量, 在系统变量中添加以下变量 ...

  5. Mysql主从安装配置

    Mysql主从安装配置   环境: 主从服务器上的MySQL数据库版本同为5.1.34 主机IP:192.168.0.1 从机IP:192.168.0.2  一. MySQL主服务器配置 1.编辑配置 ...

  6. mysql主从复制安装配置

    mysql主从复制安装配置 基础设置准备 #操作系统: centos6.5 #mysql版本: 5.7 #两台虚拟机: node1:192.168.182.111(主) node2:192.168.1 ...

  7. 记一次 mysql主从复制安装配置 过程

    mysql主从复制安装配置 1.centos安装及准备 去centos官网下载相应source版本的镜像文件并在vmware中安装,安装中会遇到填写installation source,输入以下即可 ...

  8. 虚拟机+apache+php+mysql 环境安装配置

    虚拟机的安装:直接下一步即可,注意修改路径. 安装完成后新建虚拟机,直接下一步.如果选择镜像文件后出现错误,可以试着去修改电脑bios中的虚拟化设置,改为enable,如下图: apache安装: 1 ...

  9. Linux(Ubuntu) Mysql的安装配置例子以及常用命令

    1.安装配置例子 有空再写 2.注意事项 (1)启动mysql 在/etc/mysql 目录下 service mysql start  新版本是(service mysqld start  ) (2 ...

随机推荐

  1. careercup-链表 2.7

    2.7 编写一个函数,检查链表是否为回文. 思路:1)可以利用链表中的元素采用头插法创建一个新的链表,然后比较两个链表的元素是否相等.   2)利用快慢指针,将链表后半部分逆转之后,比较前半部分与后半 ...

  2. HTTP的报文格式,GET和POST的区别

    1.HTTP报文格式 HTTP报文是面向文本的,报文中的每一个字段都是一些ASCII码串,各个字段的长度是不确定的.HTTP有两类报文:请求报文和响应报文. 请求报文: 一个HTTP请求报文由请求行( ...

  3. 如何设计一个更好的C++ ORM

    2016/11/26 "用C++的方式读写数据库,简直太棒了!" 上一篇相关文章:如何设计一个简单的C++ ORM (旧版代码)

  4. Windows PowerShell:管理服务器

    一.概述 Cmdlets 用于服务器的管理方面主要体现在4个方面:服务.日志.进程.服务器管理器. 1.服务 •  Get-Service.查看某个服务的属性. •  New-Service.创建一个 ...

  5. PS之放射背景

    效果图 素材 新建图层,填充颜色 新建图层,矩形工具画条形 滤镜-扭曲-极坐标 合并图层,效果如下 新建图层,画一个适当的圆 滤镜-模糊-高斯模糊 将素材人物抠出来放在中间

  6. C#当中的多线程_线程池

    3.1 简介 线程池主要用在需要大量短暂的开销大的资源的情形.我们预先分配一些资源在线程池当中,当我们需要使用的时候,直接从池中取出,代替了重新创建,不用时候就送回到池当中. .NET当中的线程池是受 ...

  7. Linux同步时间命令ntpdate

    转自:http://orgcent.com/linux-ntpdate/ 由于要同步Linux服务器的时间,为了保证时间的高度准确性,放弃date命令而转向ntpdate(同步时间命令). 方案如下: ...

  8. Angularjs总结(三)摸态框的使用

    静态页面: <input class="btn btnStyle " value="提 取" type="button" ng-cli ...

  9. Gulp-入门教程 搭配环境

    之前一直听朋友谈起gulp,但没有使用过,最近有机会接触到,现在给大家分享下,不对的地方还请指正.我一直以为互相分享是学习的一种好方式.下面进入正题: 首先来了解下gulp,最起码要知道:我们为什么要 ...

  10. 图像处理简单实例[OpenCV 笔记1]

    几个入门的简单程序,和对应的CMakeList, 虽然简单重新测一下写一下也是好的. CMake教程传送门 图像显示 ShowImage.cxx #include <opencv2/opencv ...