yakoffka.ru
    грабли, костыли и велосипеды php, css, html, js и прочего

    Основные команды для работы с mysql в терминале

    terminalПолные логи установки laravel на homestead, приводящей к 502 ошибке. Попытка понять, ЧЯДНТ.

    АЛАРМА!!! Это не руководство к действию!

    Капустин Яков

    оглавление

    mysql – запуск клиента MySQL
    mysql -u root -p – запуск клиента MySQL с пользователем root (с последующим вводом пароля)
    show databases; – просмотр доступных баз данных
    use ‹database_name› – выбор базы данных
    show tables; – просмотр таблиц в выбранной базе
    describe ‹table_name› – просмотр сведений о столбцах таблицы table_name
    select * from ‹table_name› – вывести все данные из таблицы table_name
    bash:
    yo@yo-Lenovo-G510:~$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.7.25-0ubuntu0.16.04.2 (Ubuntu) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | phpmyadmin | | symfony | | symfony_git | | sys | | yii2_a1 | | yii2_advanced2 | | yii2basic | +--------------------+ 10 rows in set (0,10 sec) mysql> use database symfony; ERROR 1049 (42000): Unknown database 'database' mysql> use symfony; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +-------------------+ | Tables_in_symfony | +-------------------+ | post | +-------------------+ 1 row in set (0,00 sec) mysql> describe post; +-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | title | varchar(255) | NO | | NULL | | | description | longtext | NO | | NULL | | | content | longtext | NO | | NULL | | | createdDate | datetime | NO | | NULL | | | editDate | datetime | NO | | NULL | | | author | varchar(255) | NO | | NULL | | | source | varchar(255) | YES | | NULL | | | linkSource | varchar(255) | YES | | NULL | | +-------------+--------------+------+-----+---------+----------------+ 9 rows in set (0,00 sec) mysql>

    create database ‹database_name›; – создание новой базы данных
    create table ‹table_name› [(create_definition, ...)]; – создание новой таблицы table_name
    drop database ‹database_name› – удаление базы данных database_name
    drop ‹table_name› – удаление таблицы table_name
    bash:
    vagrant@homestead:~$ mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 5.7.24-0ubuntu0.18.04.1 (Ubuntu) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | homestead | | mysql | | performance_schema | | socket_wrench | | sys | +--------------------+ 6 rows in set (0.07 sec) mysql> use homestead; Database changed mysql> show tables; mysql> exit Bye vagrant@homestead:~$