MySql导出指定列的数据
MySql导出整库或者指定表的数据使用mysqldump
命令即可,但是导出表中指定列的数据就需要用到下面命令了,如下:
1 | mysql -uroot -p123456 database_name -e "SELECT name from t_xxx where type = 3 INTO OUTFILE'/data/xxx.sql'" |
MySql导出整库或者指定表的数据使用mysqldump
命令即可,但是导出表中指定列的数据就需要用到下面命令了,如下:
1 | mysql -uroot -p123456 database_name -e "SELECT name from t_xxx where type = 3 INTO OUTFILE'/data/xxx.sql'" |
This one is for all MySQL-DBA’s, which are working on macOS. Since the Apple OS has a rather peculiar way of starting and stopping MySQL, compared to Linux, you can run into some issues. These problems occur especially, if you have no access to the GUI.
Put skip-grant-tables into the mysqld section of the my.cnf. A my.cnf can be found in /usr/local/mysql/support-files. You MUST work as root for all the following steps.
1 | sudo -s |
Save the configuration file! (In vi this is “[ESC] + :x”)
Continue with stopping MySQL:
1 | launchctl unload /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist |
Restart MySQL, so skip-grant-tables becomes active:
1 | launchctl load /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist |
After MySQL is started again, you can log into the CLI and reset the password:
1 | mysql -u root |
If you are not capable of stopping MySQL in a civilised manner, you can use the more rough way. You can send a SIGTERM to the MySQL-Server:
1 | ps -aef | grep mysql | grep -v grep |
You should receive one line. The second column from the left is the process id. Use this process id to stop the MySQL-Server.
1 | kill -15 [process id] |
In this example, the command would look like this:
1 | kill -15 28017 |
macOS will restart MySQL, since the process has not stopped correctly. The configuration will be read and the changes to the parameters will become effective. Continue with logging in to the CLI.
No matter how secure your MySQL-Password is, it is a lot more important to secure access to the server it self. If your server is not secured by something that prevents access from the internet, it will only take a few minutes for someone with bad intentions to take over your database or worse, the entire server.
decimal(M,N)
参数说明
M指定指定小数点左边和右边可以存储的十进制数字的最大个数,最大精度38。
N指定小数点右边可以存储的十进制数字的最大个数。小数位数必须是从 0 到 M之间的值。默认小数位数是 0。