- Update the OS
- sudo apt-get update
- Install MySQL
- sudo apt-get install mysql-server (You will be prompted for root password. Dont forget the password)
- It is not advisable to open mysql connections to outside of localhost. However if you must, then
- sudo vi /etc/mysql/my.cnf
- Comment out the line "bind-address 127.0.0.1"
- After install, create a non-root user ID
- mysql -u root -h 127.0.0.1 -p (when prompted enter the root password)
- create user 'userid'@'localhost' identified by 'passwd'
- grant all privileges on *.* to 'userid'@'%' identified by 'passwd' with grant option;
- flush privileges;
- quit
- Restart MySQL
- sudo /etc/init.d/mysql restart
- Create tables, Insert data, Select data
- mysql -u <userid> -h <host name> -p
- create database <db name>;
- use <db name>;
- create table test1 (fname varchar(20));
- insert into test1 values('John');
- select * from test1;
- Install a SQL GUI client (Toad or RapidSQL or SequelPro(for mac), etc)
- For bulk import of a CSV file (reference)
- mysqlimport --ignore-lines=1 --fields-terminated-by=, --columns='ID,Name,Phone,Address' --local -u root -p Database /path/to/csvfile/TableName.csv
- Happy SQLing!
Saturday, January 4, 2014
Installing MySQL on Ubuntu
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment