MySQL Script – How to pass arguments
mysql -u root -e "set @variable:=xxx; source script.sql;"
mysql -u root -e "set @variable:=xxx; source script.sql;"
Three main tasks for the basic configuration of MySQL in Linux:
1. Create the grant tables.
2. Start the server.
3. Verify server function.
For the first step we have to find the script mysql_install_db. In Ubuntu it is located in the folder /bin.
The initial account settings created with this script have no passwords associated with the accounts.
You can start the MySQL daemon with the following command in root mode:
cd /usr ; /usr/bin/mysqld_safe &
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 name-of-your-laptop password ‘new-password’
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, you’ll get output similar to that shown below:
cd mysql-test ; perl mysql-test-run.pl
./mysqladmin Ver 8.40 Distrib 4.0.22, for pc-linux on i686
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 4.0.22
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 45 sec
Threads: 1 Questions: 1 Slow Queries: 1 Opens: 6 Flush Tables: 1 Open Tables: 0 Queries per second avg: 0.022
Once the server is up and running, test it out! Put your SQL knowledge to work and ensure that you’re able to create tables and work with data. Don’t forget that one of your first tasks should be to add security to the default accounts created during the installation process.