You can also perform a combined query: MariaDB> SELECT User,Host FROM user A reasonable column to be curious about is the one called User, which, as it turns out, contains the usernames of all database users: MariaDB> SELECT User FROM user You know the columns from the results of your SHOW COLUMNS FROM user command. To view the contents of a table, use the SELECT command-but you have to know what you want to select. Rather than getting all data from a table at once, SQL enables you to select just the parts of a table you care about. Once you've identified what tables are in a database, you've started to wander into the domain of actual data. Luckily, SQL provides the SELECT command. There are a lot of columns in the user table (47, to be precise), which is a lot of data to handle. | Update_priv | varchar(1) | YES | | NULL | | | Insert_priv | varchar(1) | YES | | NULL | | | Select_priv | varchar(1) | YES | | NULL | | | Field | Type | Null| Key| Default| Extra| You can see the columns with the SHOW command, but because there are many tables to choose from, you must specify which table you want to see: MariaDB> SHOW COLUMNS FROM user Tables are two-dimensional arrays, sometimes visualized as a spreadsheet with columns and rows. For instance, you can show what tables exist in the database using SHOW again: MariaDB> SHOW TABLES Once you've switched to a database, you can run queries on it. You can make one active with the USE command: MariaDB> USE mysql To get a list of databases in your MariaDB installation: MariaDB> SHOW DATABASES Īs you can see, there are a few default databases present. The SHOW statement displays information about your database. You do need administrative functions, however, so here are the basics. If you're setting up a database for another application to use, that application handles most of the SQL for you, because that's what it's programmed to do. Unless you're designing a database from scratch or developing software that uses a database, you don't need to know much SQL. SQL isn't a vast language, but it can be nuanced and, as its name suggests, highly structured. You communicate with MariaDB through Structured Query Language (SQL) commands. To start it and to set it to autostart after a reboot: $ sudo systemctl enable -now mariadbĪlternately, you can set MariaDB to start and run until you either reboot or stop it manually: $ sudo systemctl start mariadb Connect to your databaseĪfter installation, you can open an interactive MariaDB session as root with the -user option: $ sudo mariadb -user root You've installed a database engine, but you haven't started it. Mysql Ver 15.1 Distrib 10.5.13-MariaDB, for Linux (x86_64) Start the database service You can confirm the installation using the -version option. MariaDB responds to either the mariadb or mysql command: $ mariadb -version If you're also setting up a client machine, install the client software on that machine too: $ sudo dnf install mariadb The open source implementation of MySQL is MariaDB. To install MariaDB on a Red Hat Enterprise Linux (RHEL), CentOS, or Fedora server: $ sudo dnf install mariadb mariadb-server The process for a remote one is essentially the same, except a few privileges are required to access a database outside localhost. In this article, I'll demonstrate a local MySQL install. Even when you run your database on the same server as your application, you access it through the server and client model using the loopback IP address 127.0.0.1, also known as localhost. Your web app can access your database similarly to how you access remote computers over Secure Shell (SSH). Client and serverįor web applications, databases often (although not always) run on a dedicated database server. However, before using an API, it helps to understand what's actually happening with the database engine. For this reason, there's usually a MySQL application programming interface ( API) (sometimes called a "binding") for Java, Python, Lua, PHP, Ruby, C++, and many, many other programming languages. It's common to interact with a database through a programming language.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |