mysql:mysqld、mysqld_safe、mysql、

MYSQL 启动:html

mysqld — The MySQL Server

mysqld, also known as MySQL Server, is the main program that does most of the work in a MySQL installation. MySQL Server manages access to the MySQL data directory that contains databases and tables. The data directory is also the default location for other information such as log files and status files.mysql

When MySQL server starts, it listens for network connections from client programs and manages access to databases on behalf of those clients.sql

The mysqld program has many options that can be specified at startup. For a complete list of options, run this command:shell

shell> mysqld --verbose --help

mysqld_safe — MySQL Server Startup Script

mysqld_safe  is the recommended way to start a  mysqld  server on Unix.  mysqld_safe  adds some safety features such as restarting the server when an error occurs and logging runtime information to an error log file. A description of error logging is given later in this section.数据库

mysqld_safe Options服务器

 

Format Description Introduced
--basedir Path to MySQL installation directory  
--core-file-size Size of core file that mysqld should be able to create  
--datadir Path to data directory  
--defaults-extra-file Read named option file in addition to usual option files  
--defaults-file Read only named option file  
--help Display help message and exit  
--ledir Path to directory where server is located  
--log-error Write error log to named file  
--malloc-lib Alternative malloc library to use for mysqld  
--mysqld Name of server program to start (in ledir directory)  
--mysqld-safe-log-timestamps Timestamp format for logging 5.7.11
--mysqld-version Suffix for server program name  
--nice Use nice program to set server scheduling priority  
--no-defaults Read no option files  
--open-files-limit Number of files that mysqld should be able to open  
--pid-file Path name of process ID file  
--plugin-dir Directory where plugins are installed  
--port Port number on which to listen for TCP/IP connections  
--skip-kill-mysqld Do not try to kill stray mysqld processes  
--skip-syslog Do not write error messages to syslog; use error log file  
--socket Socket file on which to listen for Unix socket connections  
--syslog Write error messages to syslog  
--syslog-tag Tag suffix for messages written to syslog  
--timezone Set TZ time zone environment variable to named value  
--user Run mysqld as user having name user_name or numeric user ID user_id  

 

/home/mypath/mysql/bin/mysqld_safe --defaults-file=/home/mypath/mysql/etc/my.cnfsocket

 /home/mypath/mysql/bin/mysqld --defaults-file=/home/mypath/mysql/etc/my.cnf --basedir=/home/my/mysql --datadir=/home/mypath/mysql/data --plugin-dir=/home/mypath /mysql/lib/plugin --log-error=/home/mypath/mysql/log/mysql.err --pid-file=/home/mypath/mysql/tmp/mysql.pid --socket=/home/mypath/mysql/tmp/mysql.sock --port=3377sqlserver

Unix系统下本地链接MySQL能够采用Unix域套接字方式,mysql.sock文件服务器与本地客户端进行通讯的Unix套接字文件,程序与mysqlserver处于同一台机器,发起本地链接时可用。该文件由参数socket指定ui

mysql>show variables like 'socket'\G;this

当MySQL实例启动时,会将本身的进程ID写入一个文件中—该文件即为pid文件。该文件可由参数pid_file控制

mysql — The MySQL Command-Line Tool

mysqladmin — Client for Administering a MySQL Server

 

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'db'

 

You may need to set up a root account for your MySQL database:

In the terminal type:

mysqladmin -u root password 'root'

And then to invoke the MySQL client:

mysql -h localhost -u root -p

mysqldump — A Database Backup Program

mysql启动问题解决:

(一)mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

没法修改密码

用 service mysqld stop

mysqld_safe --skip-grant-tables &

输入 mysql -uroot -p 回车进入

>use mysql;

> update user set password=PASSWORD("newpass")where user="root";
 更改密码为 newpassord

新建用户提示错误: 

insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));

 Field 'ssl_cipher' doesn't have a default value

那么就不用insert了,换种方法:

GRANT USAGE ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

“username”替换为将要受权的用户名,好比clientusr;

“password”替换为clientusr设置的密码;

locaohost能够改成%,方便你从别的IP登陆。

而后对你建的用户进行受权

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON database.*  TO 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mima' WITH GRANT OPTION; //对全部ip受权

本语句中的权限根据实际须要肯定:

"tablename"替换为受权访问的数据表table名

"username"是步骤2受权用户名

"password"是步骤2受权用户的设置密码

这样就为该用户授予了对某数据表的SELECT, INSERT, UPDATE, DELETE, CAREATE, DROP权限。

四、生效受权,建立完毕

一句话便可:FLUSH PRIVILEGES;

 

特别提醒注意的一点是,新版(5.7)的mysql数据库下的user表中已经没有Password字段了

而是将加密后的用户密码存储于authentication_string字段


> flush privileges; 更新权限

> quit 退出

service mysqld restart

mysql -uroot -p新密码进入

 

(二)mysql start 或 mysqld start 启动时 

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

(1)使用mysqld_safe &启动

(1)因机器内存不足致使启动失败,将配置文件 etc/my.cnf 使用mysql-small.cnf (小内存)配置

或直接加以下配置至 my.cnf

key_buffer=16K

table_open_cache=4

query_cache_limit=256K

query_cache_size=4M

max_allowed_packet=1M

sort_buffer_size=64K

read_buffer_size=256K

thread_stack=64K

innodb_buffer_pool_size = 56M

 

(三)

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'db'

You may need to set up a root account for your MySQL database:

In the terminal type:

mysqladmin -u root password 'root password goes here'

And then to invoke the MySQL client:

mysql -h localhost -u root -p
相关文章
相关标签/搜索