Use C in UsingUbuntu to develop MySQL database applications

Source: Internet
Author: User
I. Development Environment preparation 1, first of all to install Linux, here is the use of Ubuntu10.102, install MySQL series software packages, here in the 10.10 System Warehouse is MySQL5.1 version: sudoapt-getinstallmysql-serversudoapt-getinstallmysql-clientsudoapt-getinstalllibmysqlclient15-dev 2, check MySQL

I. Prepare the development environment
1. install Linux first. Ubuntu 10.10 is used here.
2. Install the MySQL software package. MySQL 10.10 is included in the system repository:
Sudo apt-get install mysql-server
Sudo apt-get install mysql-client
Sudo apt-get install libmysqlclient15-dev

Ii. Check the MySQL service status
1. view the current mysql service status
Sudo/etc/init. d/mysql status
2. You can also use the following command to check whether the mysql service has been started. If the result is blank, the mysql service has not been started:
Sudo netstat-tap | grep mysql or
Ps-ef | grep mysql

Iii. start/stop/restart the MySQL Service
1. start: sudo/etc/init. d/mysql start
2. stop: sudo/etc/init. d/mysql stop
3. restart: sudo/etc/init. d/mysql restart

4. Access the database using the MySQL client on the command line
1. Access the local host:
Mysql-uuser-ppassword db_name
2. Access the remote host:
Mysql-hhost-uuser-ppassword db_name
Note: Because the default configuration is only accessible from the local machine, you only need to comment out the bind-address line in/etc/mysql/my. cnf on www.linuxidc.com to allow remote host access.
3. perform management operations:
Use mysqladmin and Related Parameters
4. Back up the db_name database:
Mysqldump-uroot-p -- default-character-set = utf8 -- opt -- extended-insert = false -- triggers-R -- hex-blob-x db_name> bak. SQL
5. Restore the db_name database:
Mysql-uroot-p db_name <bak. SQL
6. Back up the tbl_name data table:
Select * into outfile '/usr/local/mysql/f.txt' fields terminated by '|' from tbl_name;
7. Import the file/home/a.txt to the tbl_name table in the database.
Mysql> load data local infile '/home/a.txt' into table tbl_name fields terminated by ', 'Lines terminated by' \ r \ n ';
8. Set the initial password of the mysql database root.
Shell> mysql-u root
Mysql> set password for ''@ 'localhost' = PASSWORD ('newpwd ');
Mysql> set password for ''@ 'host _ name' = PASSWORD ('newpwd ');
9. Change the password for a common user:
Mysql> set password for 'user _ name' @ 'host _ name' = PASSWORD ('newpwd ');
10. Create a Super User Account with full permissions to do anything:
Mysql> grant all privileges on *. * TO 'monty '@ 'localhost'
-> Identified by 'some _ pass' with grant option;
Mysql> grant all privileges on *. * TO 'monty '@' %'
-> Identified by 'some _ pass' with grant option;
Note: The first statement is to create an account for local connection and the second statement is to create an account for connecting from other hosts.
11. Create an account custom, which can access the bankaccount database, but can only be accessed from the Local Machine
Mysql> grant select, INSERT, UPDATE, DELETE, CREATE, DROP
-> ON bankaccount .*
-> TO 'custom' @ 'localhost'
-> Identified by 'obscure ';

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.