Unixodbc installation (MySQL UBUNTU)

Source: Internet
Author: User
Tags driver manager dsn mysql commands
The installation of unixodbc is really depressing over the past few days. Basically, every day, QT and unixodbc are compiled and installed, and sometimes some inexplicable errors may occur. First of all, I admit that I am not familiar with Linux, but the compatibility between these open-source software vendors is also too bad. Therefore, it is better to set a standard. Everyone complies with an agreement. In this sense, the monopoly of Microsoft still has some benefits.
In the end, QT still failed to be installed. There was a previous version that had been successfully compiled and installed after minor changes. I don't know why, but I was confused about how to install it later. Later, it was found that unixodbc can be installed without the QT function. Although there is no graphical interface, the core functions are available. Moreover, the driver manager will be transplanted to an embedded operating system. The more dependent components there are, the harder it will be to transplant them. Porting unixodbc to VxWorks next week may cause many problems ......
Combine the information downloaded from the Internet to summarize the latest work.
1. Install the unixodbc component:
(1). In ubuntu, it is easy to install unixodbc by using the download command of cutting-edge mode.
Apt-Get install unixodbc
(2) Use the source code, compile and install (my version is unixODBC-2.2.14)
# Tar vxzf unixODBC-2.2.14.tar.gz
# Cd unixODBC-2.2.14
#./Configure -- enable-Gui = No (do not use QT to draw the interface and add -- enable-Gui = No)
# Make
# Make install
The unixodbc component is successfully installed using the two methods described above.
2. test whether the unixodbc component can be used, that is, whether the database can be accessed through the data source.
(1) install MySQL, and you can also use the new lide download management tool.
Apt-Get install mysql-server mysql-Client
(2) Note: After MySQL is installed, the ODBC driver of MySQL is not installed. Therefore, you need to download the corresponding driver.
Apt-Get install libmyodbc
(3) write the configuration file and create your own data source
The configuration files of unixodbc are usr/local/etc/odbcinst. ini and usr/local/etc/ODBC. ini. The former is used to configure the driver, and the latter is used to save the system DSN. After installing the MySQL driver, you must enter its configuration information in/etc/odbcinst. ini. Open your favorite editor and edit/etc/odbcinst. ini:

[MySQL] 
Description = MySQL
driver for Linux Driver = /usr/lib/odbc/libmyodbc.so
Setup = /usr/lib/odbc/libodbcmyS.so
FileUsage = 1

The configuration information is followed by the driver description, driver location, configuration location, and number of driver usage. The actual driver location varies depending on the Linux release. Ubuntu is usually located under/usr/lib/ODBC. SuSE is located in/usr/lib/unixodbc /. Release versions such as RedHat may be different.

Configure the DSN, and then create a DSN named hustmysqldb. Edit usr/local/etc/ODBC. ini file

[HustMysqlDB] 
Description = The Database for HustMysql
Trace = On
TraceFile = stderr
Driver = MySQL
SERVER = localhost
USER = root
PASSWORD = mypassword
PORT = 3306
DATABASE = HustMysql

In the configuration file, The DSN name is the section name. In the configuration information, some configuration items are used by ODBC, while others are processed by the driver. If the operation is correct, ODBC is successful now. You can try the iSQL command to operate the configured DSN.
(4) test DSN
$ ISQL hustmysqldb-V

+ --------------------------------------- +
| Connected! |
|
| SQL-statement |
| Help [tablename] |
| Quit |
| + --------------------------------------- +
Note: The-V parameter is used to display debugging information, which facilitates debugging when errors occur.

In addition, paste some common MySQL commands.
1. Start MYSQL: mysqld_safe &
2. Stop MYSQL: mysqladmin-uroot-ppassw0rd shutdown. Note that there is no space after U or P.
3. Set MySQL auto-start: add the startup command to the/etc/rc. Local file.
4. Allow remote root login:

1) log on to MySQL on the local machine: mysql-u root-P (-P must be available); change the database: use MySQL;

2) from all hosts: grant all privileges on *. * to root @ "%" identified by "passw0rd" with grant option;

3) grant all privileges on *. * to root @ "192.168.11.205" identified by "passw0rd" with grant option; flush privileges;

4) Go to the MySQL database to check whether the data with host % is added: use MySQL; select * from user;

5. Create a database and create a user:

1) database creation: Create Database test1;

2) create a user and grant permissions: grant all privileges on test1. * To user_test @ "%" identified by "passw0rd" with grant option;

3) delete a database: drop database test1;

6. delete permissions:

1) Revoke all privileges on test1. * From test1 @ "% ";

2) use MySQL;

3) delete from user where user = "root" and host = "% ";

4) flush privileges;

8. display all databases: Show databases; display all tables in the database: show tables;

9. remotely log on to MySQL: mysql-h ip-u user-P

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.