方法/步骤
完成上述步骤之后,很多用户开始使用MySQL,但会出现图示的错误.这是因为没有配置环境变量所致.配置环境变量很简单:
我的电脑-属性-高级-环境变量
在其中修改或添加配置(如图):
[mysqld]
以管理员身份运行cmd(一定要用管理员身份运行,不然权限不够),
输入mysqld -install(如果不用管理员身份运行,将会因为权限不够而出现错误:Install/Remove of the Service Denied!)
安装成功
安装成功后就要启动服务了,继续在cmd中输入:net start mysql(如图),服务启动成功!
此时很多人会出现错误,请看注意:
服务启动成功之后,就可以登录了,如图,输入mysql -u root -p(第一次登录没有密码,直接按回车过),登录成功!
第一段:概述
第二段:MySQL安装
安装条件:
①.1、安装进度
第一段:mysql_install_db说明
当MySQL的系统库(mysql系统库)发生故障或需要新加一个mysql实例时,需要初始化mysql数据库.
需要使用的命令:/usr/local/mysql/bin/mysql_install_db
#/usr/local/mysql/bin/mysql_install_db --help 可以查看帮助信息如下
Usage: /usr/local/mysql/bin/mysql_install_db [OPTIONS]
--basedir=path The path to the MySQL installation directory.
--cross-bootstrap For internal use. Used when building the MySQL system
tables on a different host than the target.
--datadir=path The path to the MySQL data directory.
--force Causes mysql_install_db to run even if DNS does not
work. In that case, grant table entries that normally
use hostnames will use IP addresses.
--ldata=path The path to the MySQL data directory.
--rpm For internal use. This option is used by RPM files
during the MySQL installation process.
--skip-name-resolve Use IP addresses rather than hostnames when creating
grant table entries. This option can be useful if
your DNS does not work.
--srcdir=path For internal use. The directory under which
mysql_install_db looks for support files such as the
error message file and the file for popoulating the
help tables.
--user=user_name The login username to use for running mysqld. Files
and directories created by mysqld will be owned by this
user. You must be root to use this option. By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
All other options are passed to the mysqld program
除了支持以上的参数,还支持mysqld的参数.
第二段:举例:
修改配置文件,将端口和相关目录的都改为新的设置,如下:
[client]
user = mysql
basedir = /usr/local/mysql
......其他略
确保配置文件无误.
运行下面命令进行数据库的初始化:
第三段:启动新mysql
检查是否启动
#ps aux|grep mysql
可将启动命令加入/etc/rc.local随服务器启动
新加的mysql没有设置root密码,可以通过下面命令设置root密码: